Latest questions in Java

0 votes
1 answer

Double decimal formatting in Java

Using String.format, you can do this: double price ...READ MORE

Aug 23, 2018 in Java by parth295
• 4,640 points
43 views
0 votes
1 answer

How to replace 2 or more spaces with a single space in String and how to delete leading and trailing spaces?

before=" Hello world "; String after ...READ MORE

Aug 22, 2018 in Java by parth295
• 4,640 points
62 views
0 votes
1 answer

Why Java String class is declared as final?

String class is made final in Java ...READ MORE

Aug 21, 2018 in Java by code.reaper12
• 3,470 points
95 views
0 votes
1 answer

Iterable.forEach() vs foreach loop

The advantage comes into account when the ...READ MORE

Aug 21, 2018 in Java by parth295
• 4,640 points
119 views
0 votes
1 answer

Replace String with another in java

String s = "HelloSuresh"; s = s.replace("Hello",""); System.out.prin ...READ MORE

Aug 21, 2018 in Java by parth295
• 4,640 points
66 views
0 votes
2 answers

How to convert a byte into Hexadecimal in Java?

private static final String ...READ MORE

Aug 29, 2019 in Java by Sirajul
• 45,960 points
82 views
0 votes
1 answer

How to count the number of occurrences of an element in a List?

We can use the static frequency() method. int ...READ MORE

Aug 21, 2018 in Java by sharth
• 3,370 points
72 views
0 votes
1 answer

Gracefully stopping a java thread

The preferable way will be to use a ...READ MORE

Aug 20, 2018 in Java by anto.trigg4
• 3,440 points
51 views
0 votes
1 answer

Join array elements with a separator in Java

Using Java 8, you can easily perform ...READ MORE

Aug 16, 2018 in Java by geek.erkami
• 2,660 points
80 views
0 votes
1 answer

Checking results values using Java ResultSet

As per my knowledge what you are ...READ MORE

Aug 16, 2018 in Java by code.reaper12
• 3,470 points
37 views
0 votes
1 answer

DTO vs VO vs POJO vs JavaBeans

Data Transfer Object is used for transferring a collection ...READ MORE

Aug 14, 2018 in Java by code.reaper12
• 3,470 points
3,745 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,440 points
5,784 views
0 votes
1 answer

System.currentTimeMillis vs System.nanoTime

In case you want extremely precise measurements ...READ MORE

Aug 10, 2018 in Java by code.reaper12
• 3,470 points
604 views
+1 vote
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,600 points
6,376 views
+1 vote
1 answer

Convert CSV to JSON. JSON payload should be included in square brackets

The JSON payload uses a list and ...READ MORE

Aug 6, 2018 in Java by Omkar
• 68,860 points
2,107 views
0 votes
1 answer

@Autowired annotation in Spring Framework

The @Autowired annotation provides more accurate control over where ...READ MORE

Aug 2, 2018 in Java by geek.erkami
• 2,660 points
188 views
0 votes
1 answer

Configuration metadata in Spring Framework

Configuration metadata can be provided to Spring container in ...READ MORE

Aug 2, 2018 in Java by code.reaper12
• 3,470 points
1,814 views
0 votes
1 answer

Java execute vs executeQuery vs executeUpdate

I think the major differences between execute, executeQuery, ...READ MORE

Jul 30, 2018 in Java by geek.erkami
• 2,660 points
8,067 views
0 votes
1 answer

Overriding private or static method in Java

You cannot override a private or static ...READ MORE

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

Java Timer vs Executor Service

According to Java Concurrency in Practice: Timer is ...READ MORE

Jul 26, 2018 in Java by code.reaper12
• 3,470 points
1,257 views
0 votes
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

Jul 26, 2018 in Java by geek.erkami
• 2,660 points
633 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

Jul 25, 2018 in Java by Mrunal
• 680 points
350 views
0 votes
1 answer

Maximum depth of the java call stack

Well, there is no definite depth. It ...READ MORE

Jul 23, 2018 in Java by code.reaper12
• 3,470 points
141 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look here: https://github.com/burningwave/core/wiki/USE- ...READ MORE

Dec 20, 2019 in Java by Roberto
• 300 points

edited Dec 31, 2019 by Roberto 2,204 views
0 votes
1 answer

How to encrypt string in Java

String s1="sharth"; char[] s2=s1.toCharArray(); int s3= s2.length; ...READ MORE

Jul 23, 2018 in Java by scarlett
• 1,280 points
135 views
0 votes
1 answer

Converting a date string to a DateTime object using Joda Time library

Use DateTimeFormat: DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); DateTime dt = ...READ MORE

Jul 23, 2018 in Java by scarlett
• 1,280 points
997 views
0 votes
1 answer

Including dependencies in a jar with Maven

You can do this using the maven-assembly-plugin ...READ MORE

Jul 20, 2018 in Java by samarth295
• 2,190 points
1,965 views
0 votes
1 answer

Best XML parser for Java

If speed and memory is no problem, dom4j is ...READ MORE

Jul 20, 2018 in Java by samarth295
• 2,190 points
1,900 views
0 votes
1 answer

How to use wait() and notify() concept in producer consumer situation

In this program, we have two threads ...READ MORE

Jul 20, 2018 in Java by Kalgi
• 50,840 points
49 views
0 votes
1 answer

Running Command Line in Java

You may refer this: Runtime rt = Runtime.getRuntime(); Process ...READ MORE

Jul 20, 2018 in Java by Akrati
• 960 points
36 views
0 votes
1 answer

Which is faster amongst an Array and an ArrayList?

Array Over List: The capacity of an Array is fixed.  Whereas ArrayList can ...READ MORE

Jul 20, 2018 in Java by sophia
• 1,400 points
663 views
0 votes
1 answer

How can I calculate number of days between two dates?

You may refer this. This might work ...READ MORE

Jul 19, 2018 in Java by Akrati
• 3,150 points
354 views
0 votes
1 answer

Good Hash Function for Strings

Usually hashes wouldn't do sums, otherwise, stop and pots will have ...READ MORE

Jul 19, 2018 in Java by Akrati
• 960 points
640 views
0 votes
1 answer

What are the practical uses for AtomicInteger?

There are two main uses of AtomicInteger: As an ...READ MORE

Jul 18, 2018 in Java by Akrati
• 960 points
33 views
0 votes
1 answer

Arrays are passed by value or passed by reference in Java?

Arrays are not a primitive type in ...READ MORE

Jul 18, 2018 in Java by sophia
• 1,400 points
123 views
0 votes
2 answers

What is null in java?

"null" is a reference type and its ...READ MORE

Jul 31, 2018 in Java by Mrunal
• 680 points
50 views
0 votes
1 answer

What is casting variable in java?

Casting is, taking an Object of one ...READ MORE

Jul 17, 2018 in Java by scarlett
• 1,280 points
71 views
0 votes
1 answer

doGet and doPost in Servlets

When you are using HTTP GET requests ...READ MORE

Jul 17, 2018 in Java by Mrunal
• 680 points
1,345 views
0 votes
1 answer

Use Servlets with Ajax

Here, we are going to create the ...READ MORE

Jul 16, 2018 in Java by Akrati
• 3,150 points
837 views
0 votes
1 answer

Difference between checked and unchecked exception

Checked Exceptions : The exceptions which are checked by ...READ MORE

Jul 16, 2018 in Java by Akrati
• 3,150 points
167 views
0 votes
1 answer

What is the native keyword in Java?

The native keyword is applied to a method to ...READ MORE

Jul 16, 2018 in Java by scarlett
• 1,280 points
55 views
0 votes
1 answer

What is immutable string in java?

In java, string objects are immutable. Immutable simply ...READ MORE

Jul 16, 2018 in Java by Daisy
• 8,080 points
53 views
0 votes
1 answer

What is the array initialization syntax when not in a declaration?

Probably you'd have to ask the Java ...READ MORE

Jul 13, 2018 in Java by Akrati
• 3,150 points
28 views
0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 45,960 points
121 views
0 votes
2 answers

How do we convert JSON to Map in Java

When you don't know structure of json. ...READ MORE

Oct 31, 2018 in Java by Sushmita
• 6,880 points
550 views
0 votes
1 answer

Sort a HashMap in Java

Convert hashmap to an ArrayList with a ...READ MORE

Jul 12, 2018 in Java by Daisy
• 8,080 points
80 views
0 votes
2 answers

How to return multiple objects from a Java method?

In the event the method you're calling ...READ MORE

Aug 30, 2019 in Java by Karan
• 8,200 points
227 views
0 votes
1 answer

What does NaN mean in Java?

"NaN" stands for "not a number". "Nan" ...READ MORE

Jul 12, 2018 in Java by Akrati
• 960 points
195 views
0 votes
1 answer

How can we use wait and notify in Java?

You can refer to this: synchronized (someObject) { ...READ MORE

Jul 12, 2018 in Java by sophia
• 1,400 points
37 views
0 votes
1 answer

What is the difference between static and inner class?

An inner class, cannot be static, so ...READ MORE

Jul 11, 2018 in Java by sophia
• 1,400 points
110 views