Trending questions in Java

0 votes
1 answer

Running Java program without main method.

This would have worked fine till Java ...READ MORE

Nov 21, 2018 in Java by Anoop
30 views
0 votes
1 answer

Deep copying a 2d array in Java

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

Nov 12, 2018 in Java by code.reaper12
• 3,450 points
387 views
0 votes
1 answer

Setting time zone of a java.util.Date

You can make use of the following ...READ MORE

Aug 14, 2018 in Java by anto.trigg4
• 3,420 points
4,264 views
0 votes
2 answers

How to clear the console in Java?

import java.io.IOException; public class CLS { ...READ MORE

Aug 27, 2018 in Java by Sushmita
• 6,880 points
5,617 views
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,810 points
82 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,810 points
75 views
0 votes
1 answer

Serializing a lambda

With the release of Java 8, Oracle introduced the ...READ MORE

Nov 15, 2018 in Java by code.reaper12
• 3,450 points
72 views
0 votes
1 answer

How can I get the current date and time in UTC or GMT in Java?

This definitely returns UTC time: as String ...READ MORE

Jun 7, 2018 in Java by Rishabh
• 3,540 points
7,028 views
0 votes
1 answer

Which is the standard concise way to copy a file in Java?

As toolkit mentions above, Apache Commons IO ...READ MORE

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

Reason for java.lang.IncompatibleClassChangeError

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

Nov 13, 2018 in Java by code.reaper12
• 3,450 points
104 views
+1 vote
1 answer

Maximum memory usage for JVM

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

Nov 13, 2018 in Java by 93.lynn
• 1,560 points
45 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,810 points
61 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,810 points
34 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,050 points
736 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
77 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
30 views
0 votes
1 answer

Setting selected item of Spinner by value rather than by position

Suppose your Spinner is named newSpinner, and it contains ...READ MORE

Aug 10, 2018 in Java by 93.lynn
• 1,560 points
3,783 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,090 points
71 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,320 points
25 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,050 points
99 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,450 points
42 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,050 points
111 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,450 points
35 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,450 points
33 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,050 points
260 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,050 points
77 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,050 points
164 views
0 votes
2 answers

How to initialize multi-dimensional array in java?

a multidimensional array can define an array ...READ MORE

Mar 18 in Java by monica jesvina
78 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 26, 2018 in Java by code.reaper12
• 3,450 points
1,382 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,450 points
77 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
18 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,320 points
44 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,320 points
91 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
58 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,450 points
521 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,450 points
39 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,450 points
54 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,420 points
27 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,880 points
499 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,330 points
187 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,050 points
1,033 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,050 points
328 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
96 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
438 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,330 points
646 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
38 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,320 points
594 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,330 points
223 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,420 points
64 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,450 points
19 views