Most answered questions in Java

+16 votes
25 answers

How can I convert String to JSON object in Java?

Hi @Daisy You can use Google gson  for more ...READ MORE

Feb 7, 2019 in Java by Suresh
• 720 points
250,732 views
+7 votes
16 answers

Unable to resolve this error: "javac is not recognized as an internal or external command"

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

May 23, 2018 in Java by Rishabh
• 3,620 points
457,887 views
+2 votes
14 answers

Communications link failure: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

Your exception seems to indicate that your ...READ MORE

Dec 11, 2020 in Java by Roshni
• 10,520 points
240,798 views
+2 votes
14 answers

“A Non-static method cannot be referenced from a static context” error

Hey Techies, Non-static variables are part of the objects ...READ MORE

Dec 10, 2020 in Java by Roshni
• 10,520 points
248,252 views
0 votes
13 answers

What is the correct way to add external Jars to IntelliJ IDEA Project?

Adding custom JAR files to the EAR project Copy the custom JAR to the ...READ MORE

Dec 10, 2020 in Java by Nikita
185,682 views
+1 vote
13 answers

How does java.net.SocketException: Connection reset happen ?

You can use wireshark to view the ...READ MORE

Dec 7, 2018 in Java by tushh
249,308 views
+2 votes
13 answers

Unable to execute jar- file: “no main manifest attribute”

add a jar/manifest/attributes setting like this: apply plugin: ...READ MORE

Nov 27, 2018 in Java by krishti
214,184 views
+10 votes
13 answers

Default parameters of XMS and XMX in JVM

Run this code to see all the ...READ MORE

Nov 13, 2018 in Java by anonymous
397,458 views
+1 vote
13 answers

How to send HTTP POST requests on Java?

With Apache HttpClient In the old days, this Apache ...READ MORE

Dec 10, 2020 in Java by Rajiv
• 8,910 points
157,469 views
+1 vote
12 answers

Iterate over a JSONObject?

Assuming your JSON object is saved in ...READ MORE

Dec 11, 2020 in Java by Rajiv
• 8,910 points
122,344 views
+1 vote
12 answers

Hibernate hbm2ddl.auto possible values and their uses

hibernate.hbm2ddl.auto (e.g. none (default value), create-only, drop, create, create-drop, validate, and update) Setting to perform SchemaManagementTool actions automatically as ...READ MORE

Dec 7, 2018 in Java by Shuvodip
73,743 views
0 votes
12 answers

Java - sending HTTP parameters via POST method easily

Below are the steps we need to ...READ MORE

Dec 11, 2020 in Java by Rajiv
• 8,910 points
109,338 views
+4 votes
11 answers

How to import a jar file in Eclipse?

Click on File > Import. The Import ...READ MORE

Aug 23, 2018 in Java by Daisy
• 8,120 points
352,749 views
+1 vote
10 answers

How to make mock to void methods with mockito

You can use partial mocking to serve ...READ MORE

Dec 7, 2018 in Java by nitesh
34,347 views
+2 votes
10 answers

Convert Java Byte Array - String - Byte Array

Character Stream Vs Byte Stream Character oriented are ...READ MORE

Sep 25, 2018 in Java by carldivin
• 180 points
9,879 views
+1 vote
7 answers

What is difference between access modifier and access specifier in java

Access Specifier:- This can be understood as ...READ MORE

Feb 14, 2019 in Java by Priyaj
• 58,090 points
68,001 views
0 votes
6 answers

How can I separate the digits of an int number in Java?

You can also have a look here: To ...READ MORE

Dec 9, 2020 in Java by Roshni
• 10,520 points
204,020 views
0 votes
6 answers

How can we define global variables in java?

To define Global Variable you can make ...READ MORE

Dec 15, 2020 in Java by Gitika
• 65,910 points
115,538 views
+1 vote
5 answers

How to take input using BufferedReader in Java?

yupp i am explaining every thing .. We ...READ MORE

Feb 1, 2020 in Java by Rohan
• 180 points
117,948 views
0 votes
5 answers

How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

Jul 12, 2018 in Java by Daisy
• 8,120 points
2,186 views
0 votes
4 answers

How do I check if a file exists in Java?

To test to see if a file ...READ MORE

Dec 29, 2020 in Java by Rajiv
• 8,910 points
59,673 views
0 votes
4 answers

How to convert a char to a String?

There are two ways you can do ...READ MORE

Dec 29, 2020 in Java by Roshni
• 10,520 points
848 views
+2 votes
4 answers

Javac command not working in my windows 10

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

Aug 6, 2019 in Java by Sirajul
• 59,230 points
50,690 views
+1 vote
4 answers

How to take multiple integer input in one line using BufferedReader in Java?

To do this, we could read in ...READ MORE

Dec 14, 2020 in Java by Roshni
• 10,520 points
95,625 views
+1 vote
4 answers

What is the difference between string object and string literal?

A String literal is a Java language concept. This ...READ MORE

Aug 16, 2019 in Java by Sirajul
• 59,230 points
65,062 views
+4 votes
4 answers

Using while loop i want to print 10 even numbers

Hello @Nitesh, you are pretty much there. ...READ MORE

Nov 22, 2018 in Java by Priyaj
• 58,090 points
90,696 views
+1 vote
4 answers

What is a simple way to repeat a string in java?

There is already answer wriiten using StringBuilder ...READ MORE

Dec 16, 2020 in Java by Rajiv
• 8,910 points
28,604 views
0 votes
4 answers

“Cannot find symbol” compilation error

The "Cannot find symbol" errors generally occur when you ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
41,875 views
0 votes
4 answers

How can we display an output of float data with 2 decimal places in java? Please help

You can use DecimalFormat. One way to use ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
161,041 views
0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

Sep 5, 2018 in Java by Sushmita
• 6,910 points
990 views
0 votes
4 answers

Remove extra spaces from string in java

import java.util.regex.Matcher; import java.util.regex.Pattern; String pattern="[\\s]"; String replace=""; part="name=john age=13 year=2001"; Pattern ...READ MORE

Sep 10, 2018 in Java by Parth
• 4,630 points
2,698 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,593 views
0 votes
3 answers

How to check if a String is numeric in Java?

Check if a string is numeric public class ...READ MORE

Dec 29, 2020 in Java by Carlos
2,306 views
0 votes
3 answers

How to rotate an array from a particular index?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

May 2, 2020 in Java by oisoucknfn
1,870 views
0 votes
3 answers

How autowiring works in Spring?

First, and most important - all Spring ...READ MORE

Jan 11, 2019 in Java by developer_1
• 3,320 points
18,007 views
0 votes
3 answers

HttpServletRequest get JSON POST data

Configure the action as given below: Method: Since ...READ MORE

Dec 16, 2020 in Java by Rajiv
• 8,910 points
66,960 views
+1 vote
3 answers

3 dot in parameter in Java

The "Three Dots" in java is called ...READ MORE

Nov 22, 2018 in Java by geek.erkami
• 2,680 points
53,541 views
0 votes
3 answers

How does the “final” keyword in Java work?

Final is a keyword that is used to ...READ MORE

Sep 1, 2019 in Java by DEEPAK KUMAR GUPTA
1,900 views
+12 votes
3 answers

How do I set or change the PATH system variable?

First make sure you have installed JDK ...READ MORE

Aug 28, 2018 in Java by slayer
• 29,350 points
985 views
0 votes
3 answers

Setting time zone of a java.util.Date

Using Java 8 Java 8 introduced a new Date-Time ...READ MORE

Dec 15, 2020 in Java by Gitika
• 65,910 points
55,539 views
+29 votes
3 answers

How can we set java.library.path in Eclipse?

Go into the library settings for your ...READ MORE

Jul 3, 2018 in Java by sharth
• 3,370 points
21,051 views
0 votes
3 answers

What is ^ operator in java?

It's bitwise XOR, Java does not have ...READ MORE

Oct 31, 2018 in Java by Sushmita
• 6,910 points
758 views
0 votes
3 answers

Is there any goto statement in java?

So they could be used one day ...READ MORE

Oct 15, 2018 in Java by Daisy
• 8,120 points
935 views
+2 votes
3 answers

Listing all the subclasses of a specific class in Java

Try with BurningWave core library. Here an ...READ MORE

Dec 29, 2019 in Java by anonymous
• 460 points

edited Jan 9, 2020 by anonymous 13,108 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

Aug 29, 2018 in Java by Daisy
• 8,120 points
1,317 views
0 votes
3 answers

Does Java support Default Parameters?

You can try this with method overloading. void ...READ MORE

Sep 21, 2018 in Java by Sushmita
• 6,910 points
6,596 views
0 votes
3 answers

Change date format in a Java string

The reason for the inaccuracy is because ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
2,848 views
0 votes
3 answers

How to clear the console in Java?

import java.io.IOException; public class chkClearScreen {     public static void ...READ MORE

Aug 26, 2020 in Java by ItsJustRaja
35,341 views
+1 vote
3 answers

How to convert a List to an Array in Java?

Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE

Aug 7, 2018 in Java by Akrati
• 3,190 points
888 views
+1 vote
3 answers

Copy Java Array and make a duplicate of it

int[] a = {1,2,3,4,5}; int[] b = Arrays.copyOf(a, ...READ MORE

Aug 30, 2018 in Java by Sushmita
• 6,910 points
1,388 views