Trending questions in Java

0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

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

What is the 'instanceof' operator used for in Java?

It's an operator that returns true if ...READ MORE

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

How to clone ArrayList and also clone its contents?

Iterate on the items, and clone them ...READ MORE

Jun 5, 2018 in Java by Akrati
• 3,190 points
709 views
0 votes
1 answer

What does Java option -Xmx stand for?

-Xmxn: It specifies the maximum size, in bytes, ...READ MORE

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

what does javabean actually means?

A JavaBean is just a standard All properties ...READ MORE

Jun 7, 2018 in Java by anonymous
708 views
0 votes
1 answer

How does contains() method work in evaluating objects?

Generally you should also override hashCode() each time you ...READ MORE

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

The best way to filter a Java Collection?

 this problem is solved using streams and ...READ MORE

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

Can Static methods be inherited in java?

A subclass inherits all of the public ...READ MORE

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

parse int value from a char

Check Character.getNumericValue(char). String element = "el7"; int x = Character.getNumericValue(element.charAt(2)); System.out.println("x=" ...READ MORE

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

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

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

How to set a timer in Java?

To work on timer in java, you ...READ MORE

May 16, 2018 in Java by Daisy
• 8,140 points
1,332 views
0 votes
1 answer

Overloaded method for null in Java

The method invoked here will be the ...READ MORE

May 23, 2018 in Java by code.reaper12
• 3,500 points
1,017 views
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
804 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
790 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,499 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
693 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
924 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,565 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,290 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,320 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,199 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
813 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,542 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
1,097 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
894 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,316 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,189 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
1,104 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,098 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
947 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
811 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
741 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,382 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
1,037 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
992 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
904 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
995 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
941 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
1,115 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,475 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,402 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,181 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
801 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,256 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
1,015 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
832 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,221 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
918 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,318 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,337 views