Most answered questions in Java

0 votes
1 answer

How to force garbage collection in Java?

Your best option is to call System.gc() which simply ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
833 views
0 votes
1 answer

What is the maximum Java heap size of a 32-bit JVM on a 64-bit OS?

32-bit JVMs which expect to have a ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
2,689 views
0 votes
1 answer

How to change selection listener in JComboBox?

It should respond to ActionListeners, like this: combo.addActionListener (new ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
880 views
0 votes
1 answer

Reason for java.lang.IncompatibleClassChangeError

Well these kinda error generally occur when ...READ MORE

Nov 14, 2018 in Java by code.reaper12
• 3,500 points
1,807 views
+1 vote
1 answer

Maximum memory usage for JVM

I guess, you can try using the ...READ MORE

Nov 14, 2018 in Java by 93.lynn
• 1,600 points
1,427 views
0 votes
1 answer

What is Enum in Java?

 It means that the type argument for ...READ MORE

Nov 13, 2018 in Java by Frankie
• 9,830 points
627 views
0 votes
1 answer

How to call a method from Constructor?

Have a glance at below steps: You create ...READ MORE

Nov 13, 2018 in Java by Frankie
• 9,830 points
6,506 views
0 votes
1 answer

Why clone() method is protected in Java?

The clone() is protected because it is ...READ MORE

Nov 13, 2018 in Java by geek.erkami
• 2,680 points
4,244 views
0 votes
1 answer

Deep copying a 2d array in Java

I guess, for deep copying you will ...READ MORE

Nov 13, 2018 in Java by code.reaper12
• 3,500 points
8,462 views
0 votes
1 answer

3DES encryption/decryption in Java

Hey, its just that Base 64 encoding ...READ MORE

Nov 8, 2018 in Java by nirvana
• 3,130 points
10,675 views
0 votes
1 answer

HTML Parsing in Java

Well, to parse HTML I used JTidy.  Basically, ...READ MORE

Nov 2, 2018 in Java by geek.erkami
• 2,680 points
334 views
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,500 points
932 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,500 points
620 views
0 votes
1 answer

Affinity in Java thread

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

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

Default Object.toString() in hashcode

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

Oct 31, 2018 in Java by code.reaper12
• 3,500 points
764 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,120 points
3,948 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,120 points
568 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,120 points
5,574 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,219 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,218 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
688 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,302 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,600 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,899 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
557 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
582 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
340 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
347 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,010 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
549 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,138 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
391 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,733 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,797 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
882 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,192 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,645 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
381 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
735 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,980 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
580 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,120 points
669 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,378 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
589 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,671 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,641 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
526 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,580 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
605 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,416 views