Latest questions in Java

0 votes
1 answer

Why do we use threads in Java?

Reasons for using Multithreading in Java: When a ...READ MORE

Nov 2, 2018 in Java by nsv999
• 5,510 points
96 views
0 votes
2 answers

Maximum size of an Java array

There are actually two limits.  The maximum element ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 44,350 points
933 views
0 votes
1 answer

varargs in Java

Well, varargs are generally used to deal ...READ MORE

Oct 31, 2018 in Java by code.reaper12
• 3,470 points
57 views
0 votes
1 answer

Affinity in Java thread

Well, as far as I know, I ...READ MORE

Oct 30, 2018 in Java by code.reaper12
• 3,470 points
55 views
0 votes
1 answer

Default Object.toString() in hashcode

Well, the hash code object is the ...READ MORE

Oct 30, 2018 in Java by code.reaper12
• 3,470 points
55 views
0 votes
2 answers

How to convert List<Integer> to int[] in Java?

In addition to Commons Lang, you can ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 44,350 points
1,410 views
0 votes
1 answer

How to determine day of week by passing specific date?

You can use java.util.Calendar: Calendar c = Calendar.getInstance(); c.setTime(yourDate); int dayOfWeek ...READ MORE

Oct 30, 2018 in Java by Daisy
• 8,080 points
225 views
0 votes
1 answer

Error - trustAnchors parameter must be non-empty

This bizarre message means that the truststore ...READ MORE

Oct 29, 2018 in Java by Daisy
• 8,080 points
102 views
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,080 points
305 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,880 points
31 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,080 points
529 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,660 points
65 views
0 votes
1 answer

Splitting a string between letters and digits

Maybe you can try splitting the String ...READ MORE

Oct 25, 2018 in Java by code.reaper12
• 3,470 points
123 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,080 points
1,156 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,080 points
596 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
• 44,350 points
57 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,880 points
98 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,660 points
115 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,470 points
53 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 22, 2018 in Java by code.reaper12
• 3,470 points
60 views
0 votes
1 answer

Number of Characters in Java String

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

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

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

The annotation @JoinColumn indicates that this entity is the owner of ...READ MORE

Oct 18, 2018 in Java by Sushmita
• 6,880 points
4,263 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
226 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 parth295
• 4,640 points
57 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
• 44,350 points
110 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,880 points
161 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,470 points
28 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
190 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,470 points
1,123 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
90 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
908 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,080 points
638 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
34 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,470 points
75 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 10, 2018 in Java by code.reaper12
• 3,470 points
3,295 views
0 votes
1 answer

How to use ThreadLocal variable

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

Oct 10, 2018 in Java by code.reaper12
• 3,470 points
37 views
+2 votes
1 answer

What is the meaning of "this" keyword in Java?

public class MyThisTest { private int ...READ MORE

Oct 10, 2018 in Java by Daisy
• 8,080 points
67 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,080 points
289 views
0 votes
1 answer

Tail call optimization in JVM

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

Oct 9, 2018 in Java by geek.erkami
• 2,660 points
49 views
0 votes
1 answer

$ in a variable name in Java

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

Oct 9, 2018 in Java by code.reaper12
• 3,470 points
40 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,880 points
206 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,080 points
59 views
0 votes
1 answer

Java's default package

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

Oct 8, 2018 in Java by code.reaper12
• 3,470 points
41 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 8, 2018 in Java by anto.trigg4
• 3,440 points
124 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
• 7,520 points
114 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
47 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 parth295
• 4,640 points
711 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
119 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,880 points
50 views
0 votes
1 answer

Escaping strings in JSON

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

Oct 3, 2018 in Java by geek.erkami
• 2,660 points
772 views