Most voted questions in Java

0 votes
1 answer

How to parse date string to Date?

The pattern is wrong. You have a ...READ MORE

Oct 29, 2018 in Java by Daisy
• 8,120 points
5,562 views
0 votes
1 answer

How can we encrypt a String in Java?

Let's assume the bytes to encrypt are ...READ MORE

Oct 26, 2018 in Java by Sushmita
• 6,910 points
1,202 views
0 votes
1 answer

How to run Unix shell script from Java code?

ProcessBuilder pb = new ProcessBuilder("myshellScript.sh", "myArg1", "myArg2"); ...READ MORE

Oct 26, 2018 in Java by Daisy
• 8,120 points
6,207 views
0 votes
1 answer

Java String interning

The String.intern() method of Java Strings ensures ...READ MORE

Oct 25, 2018 in Java by geek.erkami
• 2,680 points
680 views
0 votes
2 answers

Splitting a string between letters and digits

Using Python: https://stackoverflow.com/a/63936955/8117673 READ MORE

Sep 17, 2020 in Java by Himanshu
4,134 views
0 votes
1 answer

Eclipse java debugging: source not found

Eclipse debugging works with the class actually loaded by ...READ MORE

Oct 25, 2018 in Java by Daisy
• 8,120 points
7,286 views
0 votes
1 answer

Ignoring new fields on JSON objects using Jackson

Jackson provides an annotation that can be ...READ MORE

Oct 25, 2018 in Java by Daisy
• 8,120 points
2,574 views
0 votes
2 answers

Java: convert List<String> to a String

With a java 8 collector, this can ...READ MORE

Aug 30, 2019 in Java by Sirajul
• 59,230 points
562 views
0 votes
1 answer

How to encode the HTTP URL address in Java?

Use one of the constructors with more ...READ MORE

Oct 23, 2018 in Java by Sushmita
• 6,910 points
2,882 views
0 votes
1 answer

Usage of abstract class and interface

Well let me draw a clear line ...READ MORE

Oct 23, 2018 in Java by geek.erkami
• 2,680 points
551 views
0 votes
1 answer

Optional return type of getter() in Java 8

Well, you can do that but originally ...READ MORE

Oct 23, 2018 in Java by code.reaper12
• 3,500 points
570 views
0 votes
1 answer

Recursively delete directories in Java

You can try using the FileUtils class of Apache's commons-io: FileUtils.deleteDirectory(new ...READ MORE

Oct 23, 2018 in Java by code.reaper12
• 3,500 points
335 views
0 votes
1 answer

Number of Characters in Java String

I think you can make use of ...READ MORE

Oct 23, 2018 in Java by anto.trigg4
• 3,440 points
338 views
0 votes
2 answers

What's the difference between @JoinColumn and mappedBy when using a JPA @OneToMany association?

JPA mapping annotation can be classified as ...READ MORE

Oct 28, 2020 in Java by bjjj
• 140 points
20,327 views
0 votes
1 answer

Why “non-static method cannot be referenced from a static context”?

You can't call something that doesn't exist. ...READ MORE

Oct 17, 2018 in Java by sharth
• 3,370 points
1,000 views
0 votes
1 answer

What is the meaning of 'Synchronized'?

The synchronized keyword is about different threads reading and ...READ MORE

Oct 17, 2018 in Java by Parth
• 4,630 points
543 views
0 votes
2 answers

What are all the different ways to create an object in Java?

There are different ways you could do this ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 59,230 points
863 views
0 votes
1 answer

Remote debugging a Java application

I noticed that some people are cutting ...READ MORE

Oct 16, 2018 in Java by Sushmita
• 6,910 points
1,129 views
0 votes
1 answer

Importing properties file from Java package

In case your class is present within ...READ MORE

Oct 15, 2018 in Java by code.reaper12
• 3,500 points
384 views
0 votes
1 answer

Writing a UTF-8 file with Java

You can make use of a FileOutputStream rather than ...READ MORE

Oct 15, 2018 in Java by anto.trigg4
• 3,440 points
1,726 views
0 votes
1 answer

Retrieving query from java.sql.PreparedStatement

By using prepared statements, you can't retrieve the query ...READ MORE

Oct 12, 2018 in Java by code.reaper12
• 3,500 points
15,734 views
0 votes
1 answer

Static methods can't be abstract in Java

Well, Java doesn't allow this because of ...READ MORE

Oct 12, 2018 in Java by v.liyyah
• 1,300 points
861 views
0 votes
1 answer

How to build jars from IntelliJ properly?

How to build a jar with IntelliJ ...READ MORE

Oct 12, 2018 in Java by sharth
• 3,370 points
7,166 views
0 votes
1 answer

Evaluating a math expression given in string form

import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; public class Test { ...READ MORE

Oct 12, 2018 in Java by Daisy
• 8,120 points
5,634 views
0 votes
1 answer

Randomly selecting an element from an array

For randomly selecting an element, java.util.Random provides ...READ MORE

Oct 11, 2018 in Java by anto.trigg4
• 3,440 points
368 views
0 votes
1 answer

Java equals() vs Arrays.equals()

Here, array1.equals(array2)meansarray1 == array2 That is, it checks whether ...READ MORE

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

How to refresh a JTable model after insert delete or update the data

In my opinion, you can notify your ...READ MORE

Oct 11, 2018 in Java by code.reaper12
• 3,500 points
23,900 views
0 votes
1 answer

How to use ThreadLocal variable

You can use a ThreadLocal variable when you have some ...READ MORE

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

How can we handle the javax.net.ssl.SSLHandshakeException?

import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import java.io.OutputStream; // ...READ MORE

Oct 10, 2018 in Java by Daisy
• 8,120 points
2,369 views
0 votes
1 answer

Tail call optimization in JVM

The tail call optimization in JVM is difficult ...READ MORE

Oct 10, 2018 in Java by geek.erkami
• 2,680 points
575 views
0 votes
1 answer

$ in a variable name in Java

Java compiler uses "$" symbol internally to decorate ...READ MORE

Oct 10, 2018 in Java by code.reaper12
• 3,500 points
5,650 views
0 votes
2 answers

How to parse/format dates with LocalDateTime? (Java 8)

Converting LocalDateTime to Time Zone ISO8601 String LocalDateTime ...READ MORE

Dec 6, 2018 in Java by Sushmita
• 6,910 points
3,790 views
0 votes
1 answer

Creating an instance using the class name and calling constructor

Yes: Class<?> clazz = Class.forName(className); Constructor<?> ctor = clazz.getConstructor(String.class); Object ...READ MORE

Oct 9, 2018 in Java by Daisy
• 8,120 points
2,624 views
0 votes
1 answer

Java's default package

Yes, technically, using the package names should ...READ MORE

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

Can't access static fields in inner classes in Java

Well, the major idea behind this concept ...READ MORE

Oct 9, 2018 in Java by anto.trigg4
• 3,440 points
1,566 views
0 votes
2 answers

Reading an InputStream & coverting it into a String in Java?

Apache Commons allows: String myString = IOUtils.toString(myInputStream, "UTF-8"); And ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
846 views
0 votes
1 answer

How to display an animated GIF?

Android actually can decode and display animated ...READ MORE

Oct 8, 2018 in Java by sharth
• 3,370 points
599 views
0 votes
1 answer

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: How to handle this exception?

You have a com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure java.net.ConnectException: ...READ MORE

Oct 8, 2018 in Java by Parth
• 4,630 points
2,403 views
0 votes
2 answers

Why are you not able to declare a class as static in Java?

A static keyword  can be used with ...READ MORE

Jun 11, 2019 in Java by Neha
• 330 points
1,130 views
0 votes
2 answers

How to parse a date?

SimpleDateFormat parser=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz ...READ MORE

Dec 6, 2018 in Java by Sushmita
• 6,910 points
637 views
0 votes
1 answer

Escaping strings in JSON

You can find a JSON library in your ...READ MORE

Oct 4, 2018 in Java by geek.erkami
• 2,680 points
23,808 views
0 votes
1 answer

How do you produce a double in Java

double num = 5; When you do this, ...READ MORE

Oct 4, 2018 in Java by anto.trigg4
• 3,440 points
579 views
0 votes
1 answer

How to Read/Write String from a File in Android

Writing a File in android: private void writeToFile(String ...READ MORE

Oct 3, 2018 in Java by sharth
• 3,370 points
6,970 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,889 views
0 votes
1 answer

Non-static method within Static method in Java

As per my knowledge, you are getting this error ...READ MORE

Sep 28, 2018 in Java by anto.trigg4
• 3,440 points
1,039 views
0 votes
1 answer

System.exit() method in Java

System.exit() is a method of System class ...READ MORE

Sep 28, 2018 in Java by code.reaper12
• 3,500 points
1,277 views
0 votes
1 answer

“Missing return statement” within if / for / while in Java

Putting a return statement in any of the ...READ MORE

Sep 27, 2018 in Java by code.reaper12
• 3,500 points
8,690 views
0 votes
2 answers

Does Java thread.sleep() puts swing ui to sleep?

You are correct about the code putting ...READ MORE

Oct 24, 2018 in Java by Sushmita
• 6,910 points
4,615 views
0 votes
1 answer

Find Oracle JDBC driver in Maven repository

Download the jar and place it in ...READ MORE

Sep 26, 2018 in Java by Daisy
• 8,120 points
2,965 views
0 votes
1 answer

What is the best Java email address validation method?

Apache Commons is generally known as a ...READ MORE

Sep 26, 2018 in Java by Parth
• 4,630 points
551 views