Trending questions in Java

0 votes
1 answer

How to implement constants in java

Here is the solution- public static final TYPE ...READ MORE

May 28, 2018 in Java by sophia
• 1,400 points
693 views
0 votes
1 answer

Use of Static Keyword in a Class

It means that there is only one ...READ MORE

May 29, 2018 in Java by Rishabh
• 3,620 points
678 views
0 votes
1 answer

Unexpected result on Subtracting Times

ou've encountered a local time discontinuity: When local standard ...READ MORE

May 29, 2018 in Java by Rishabh
• 3,620 points
617 views
0 votes
1 answer

Working of post increment operator in Java

Well, I think the confusion is because ...READ MORE

May 23, 2018 in Java by geek.erkami
• 2,680 points
833 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

May 10, 2018 in Java by Rishabh
• 3,620 points
1,353 views
0 votes
1 answer

Implement Tree(Datastructure) in Java

I wrote a small "TreeMap" class based ...READ MORE

May 9, 2018 in Java by sharth
• 3,370 points
1,448 views
0 votes
1 answer

How can a war file be deployed in Tomcat 7?

You can access your application from: http://localhost:8080/sample Deploying ...READ MORE

Apr 20, 2018 in Java by sophia
• 1,400 points
2,111 views
0 votes
1 answer

Can Abstract Class have a Constructor?

Yes, an abstract class can have a ...READ MORE

May 11, 2018 in Java by sharth
• 3,370 points
1,197 views
0 votes
1 answer

How to remove ‘char’ from a String?

Hi...here you can try using the overloaded ...READ MORE

May 22, 2018 in Java by code.reaper12
• 3,500 points
719 views
0 votes
1 answer

HashMap vs LinkedHashMap vs TreeMap

Hi, there is no as such difference ...READ MORE

May 5, 2018 in Java by v.liyyah
• 1,300 points
1,444 views
0 votes
1 answer

How can I make the return type of a method generic?

First of all, define callFriend: public <T extends ...READ MORE

May 19, 2018 in Java by sharth
• 3,370 points
810 views
0 votes
1 answer

What is the difference between jdk and jre?

JRE: It stands for Java Runtime Environment. ...READ MORE

Apr 20, 2018 in Java by Akrati
• 3,190 points
2,014 views
0 votes
1 answer

How to get the number of digits in an int?

You can find out the length of ...READ MORE

May 14, 2018 in Java by Akrati
• 3,190 points
980 views
0 votes
1 answer

In which class is the "length" property of array defined ?

It's defined in the Java language specification: The members ...READ MORE

May 8, 2018 in Java by Rishabh
• 3,620 points
1,173 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

May 11, 2018 in Java by code.reaper12
• 3,500 points
1,070 views
0 votes
1 answer

What is Java Enterprise Edition ?

Is Java EE just a specification? What ...READ MORE

May 14, 2018 in Java by Rishabh
• 3,620 points
877 views
0 votes
1 answer

How to reverse an int array in Java?

for(int i = 0; i < Data.length ...READ MORE

May 11, 2018 in Java by Akrati
• 3,190 points
1,010 views
0 votes
1 answer

What is ArrayIndexOutOfBoundsException ?

If You check System.out.print(names.length); you will get 3 ...READ MORE

May 11, 2018 in Java by sharth
• 3,370 points
973 views
0 votes
1 answer

How can I get Key from their respective Values

public class NewClass1 { ...READ MORE

May 16, 2018 in Java by Parth
• 4,640 points
705 views
0 votes
1 answer

Replacing a String with a character

Yes, you are missing out on a ...READ MORE

May 17, 2018 in Java by geek.erkami
• 2,680 points
647 views
0 votes
1 answer

Perform "Switch-case" on String in Java

Switches based on integers can be optimized ...READ MORE

May 8, 2018 in Java by Rishabh
• 3,620 points
964 views
0 votes
1 answer

How do I join 2 lists

This is not a simpler method, but ...READ MORE

May 11, 2018 in Java by sharth
• 3,370 points
824 views
0 votes
1 answer

Converting String and Float Data-types

Using Java’s Float class. float f = Float.parseFloat("25"); String s = ...READ MORE

May 9, 2018 in Java by developer_1
• 3,350 points
854 views
0 votes
1 answer

Difference between String.equals() and ==

Though both are used for comparison, but the ...READ MORE

May 7, 2018 in Java by geek.erkami
• 2,680 points
913 views
0 votes
1 answer

Convert String type to byte[] in Java

Try using String.getBytes(). It returns a byte[] ...READ MORE

May 8, 2018 in Java by Rishabh
• 3,620 points
858 views
0 votes
1 answer

What is the difference between Runnable and extends Thread

Runnable is the preferred way to create ...READ MORE

May 1, 2018 in Java by sharth
• 3,370 points
1,199 views
0 votes
1 answer

How to calculate the difference between two date instances in Java?

You can use Joda Time Library. Interval i ...READ MORE

May 4, 2018 in Java by Parth
• 4,640 points
991 views
0 votes
1 answer

How can I create an executable JAR with dependencies using Maven?

<build> <plugins> <plugin> ...READ MORE

Apr 26, 2018 in Java by sophia
• 1,400 points
1,300 views
0 votes
1 answer

Need for finalize() in Java

finalize() is a method called by the ...READ MORE

May 9, 2018 in Java by code.reaper12
• 3,500 points
708 views
0 votes
1 answer

How to pad string in Java?

Padding to 10 characters: String.format("%10s", "foo").replace(' ', '*'); String.format("%-10s", ...READ MORE

May 1, 2018 in Java by Rishabh
• 3,620 points
1,058 views
0 votes
1 answer

difference between wait() and sleep() in java

We can find a big difference between ...READ MORE

Apr 26, 2018 in Java by developer_1
• 3,350 points
1,266 views
0 votes
1 answer

How can I read a large text file line by line using Java?

// Open the file FileInputStream file = new ...READ MORE

May 2, 2018 in Java by Parth
• 4,640 points
914 views
0 votes
1 answer

What are optional parameters in Java

Using three dots: public void move(Object... x) { ...READ MORE

Apr 27, 2018 in Java by developer_1
• 3,350 points
1,033 views
0 votes
1 answer

Reflection: Explanation and Uses

Reflection API is used to modify or examine the behavior ...READ MORE

May 2, 2018 in Java by sharth
• 3,370 points
747 views
0 votes
1 answer

what are the ways in which a list can be iterated

  There are 5 ways to iterate over ...READ MORE

Apr 23, 2018 in Java by sharth
• 3,370 points
1,116 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

Apr 19, 2018 in Java by Rishabh
• 3,620 points
1,214 views
0 votes
1 answer

What do we understand from string pool in java?

This prints true (even though we don't use equals method: correct ...READ MORE

Apr 30, 2018 in Java by Daisy
• 8,140 points
737 views
0 votes
1 answer

Sorted array is being processed faster than unsorted array. Why is it so ?

What is Branch Prediction? Consider a railroad junction: Image by ...READ MORE

Apr 18, 2018 in Java by Rishabh
• 3,620 points
1,234 views
0 votes
1 answer

How can I Sort an ArrayList in Java

You can sort the ArrayList in 2 ...READ MORE

Apr 23, 2018 in Java by sharth
• 3,370 points
882 views
0 votes
1 answer

Sort a Map<Key, Value> by values

This might help solve your problem...!!!! public class ...READ MORE

Apr 18, 2018 in Java by Rishabh
• 3,620 points
1,032 views
0 votes
1 answer

How to divide a string in two parts

String s="yourstring"; boolean flag = true; for(int i=0;i<s.length();i++) { ...READ MORE

Apr 13, 2018 in Java by Rishabh
• 3,620 points
1,227 views
0 votes
1 answer

I am learning looping statements. Can you tell me how 'for-each' works in Java?

While programming we often write code that ...READ MORE

Apr 17, 2018 in Java by Rishabh
• 3,620 points
957 views
0 votes
1 answer

How to print java array in the simplest way?

String[] arr = new String[] {"John", "Mary", ...READ MORE

Apr 17, 2018 in Java by sophia
• 1,400 points
853 views
0 votes
1 answer

How do I fix a NullPointerException?

When you declare a reference variable (i.e. ...READ MORE

Apr 13, 2018 in Java by Parth
• 4,640 points
979 views
0 votes
1 answer

How to take input from users?

Scanner Class is used to take input ...READ MORE

Apr 17, 2018 in Java by Akrati
• 3,190 points
815 views
0 votes
0 answers

Ho do I Iterate through a HashMap which contains duplicate values

What is the fastest and the best ...READ MORE

Apr 16, 2018 in Java by Daisy
• 8,140 points
825 views