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 Parth
• 4,630 points
405 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 Parth
• 4,630 points
544 views
0 votes
1 answer

Why Java String class is declared as final?

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

Aug 22, 2018 in Java by code.reaper12
• 3,500 points
5,429 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 Parth
• 4,630 points
576 views
0 votes
1 answer

Replace String with another in java

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

Aug 21, 2018 in Java by Parth
• 4,630 points
625 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
• 59,230 points
1,756 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
5,320 views
0 votes
1 answer

Gracefully stopping a java thread

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

Aug 21, 2018 in Java by anto.trigg4
• 3,440 points
1,021 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,680 points
2,124 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,500 points
484 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,500 points

edited Oct 7, 2021 by Sarfaraz 11,123 views
0 votes
3 answers

Setting time zone of a java.util.Date

Using Java 8 Java 8 introduced a new Date-Time ...READ MORE

Dec 15, 2020 in Java by Gitika
• 65,910 points
55,513 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,500 points
2,885 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
21,078 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 7, 2018 in Java by Omkar
• 69,210 points
9,244 views
0 votes
1 answer

@Autowired annotation in Spring Framework

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

Aug 3, 2018 in Java by geek.erkami
• 2,680 points
1,434 views
0 votes
1 answer

Configuration metadata in Spring Framework

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

Aug 3, 2018 in Java by code.reaper12
• 3,500 points
12,071 views
0 votes
1 answer

Java execute vs executeQuery vs executeUpdate

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

Jul 31, 2018 in Java by geek.erkami
• 2,680 points
23,987 views
0 votes
1 answer

Overriding private or static method in Java

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

Jul 31, 2018 in Java by code.reaper12
• 3,500 points
14,819 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,500 points
5,675 views
+1 vote
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,680 points
3,377 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 26, 2018 in Java by Mrunal
• 680 points
1,675 views
0 votes
1 answer

Maximum depth of the java call stack

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

Jul 24, 2018 in Java by code.reaper12
• 3,500 points
1,941 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look to this example: https://github.com/burningwave/co ...READ MORE

Dec 21, 2019 in Java by Roberto
• 460 points

edited Jul 7, 2020 by Roberto 36,690 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 24, 2018 in Java by scarlett
• 1,290 points
1,464 views
+1 vote
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 24, 2018 in Java by scarlett
• 1,290 points
4,457 views
0 votes
1 answer

Including dependencies in a jar with Maven

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

Jul 21, 2018 in Java by samarth295
• 2,220 points
14,882 views
0 votes
1 answer

Best XML parser for Java

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

Jul 21, 2018 in Java by samarth295
• 2,220 points
7,236 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
• 52,360 points
898 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
537 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
27,594 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,190 points
1,042 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
3,447 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
504 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
9,705 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
674 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,290 points
438 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
5,115 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,190 points
3,578 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,190 points
3,094 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,290 points
500 views
0 votes
2 answers

What is immutable string in java?

To answer your question, the String is ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
627 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,190 points
385 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
• 59,230 points
1,505 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,910 points
5,479 views
0 votes
1 answer

Sort a HashMap in Java

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

Jul 13, 2018 in Java by Daisy
• 8,120 points
503 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
• 19,610 points
8,298 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
1,705 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
471 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
1,012 views