Most voted questions in Java

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,445 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,094 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
24,014 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,883 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,689 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,688 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,945 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,473 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,919 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,251 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
905 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
544 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,614 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,049 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,455 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
510 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,740 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
684 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
445 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,135 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,588 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,106 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
508 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
638 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
392 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,519 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,499 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
510 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,334 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,724 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
481 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,019 views
0 votes
1 answer

Check whether the string is palindrome or not?

You may refer the below code: public static ...READ MORE

Jul 11, 2018 in Java by Akrati
• 3,190 points
900 views
0 votes
2 answers

Is there any way to declare an array in-line?

Another way to do that, if you ...READ MORE

Aug 30, 2019 in Java by Sirajul
• 59,230 points
407 views
0 votes
1 answer

org.xml.sax.SAXParseException: How to handle this exception?

This is often caused by a white ...READ MORE

Jul 9, 2018 in Java by sharth
• 3,370 points
5,731 views
0 votes
2 answers

How to play .mp3 and .wav in Java?

We can use Java API to play ...READ MORE

Dec 7, 2018 in Java by Sushmita
• 6,910 points
5,432 views
0 votes
2 answers

What is the difference between Type List and type ArrayList in Java

By List, you actually tell, that your object ...READ MORE

Aug 28, 2019 in Java by Sirajul
• 59,230 points
2,282 views
0 votes
2 answers

How may I programmatically determine operating system in Java?

Use the following program public class Osname {        public ...READ MORE

Jul 6, 2018 in Java by Priyaj
• 58,090 points
553 views
0 votes
2 answers

Give an example for encryption and decryption in AES using Java

getfullstring: Splashscreen.text >>> READ MORE

May 8, 2019 in Java by anonymous
6,600 views
0 votes
1 answer

Is there any way to write content of Java InputStream to an OutputStream?

org.apache.commons.io.IOUtils from Apache has a method called copy(InputStream,OutputStream).which does ...READ MORE

Jul 6, 2018 in Java by sharth
• 3,370 points
588 views
0 votes
1 answer

How can we return a JSON object from a Java Servlet?

response.setContentType("application/json"); // Get the printwriter object from response ...READ MORE

Jul 6, 2018 in Java by sharth
• 3,370 points
5,647 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

Jul 6, 2018 in Java by Akrati
• 3,190 points
761 views
0 votes
1 answer

How to get the name of the currently executing method?

Thread.currentThread().getStackTrace() will usually contain the method you’re ...READ MORE

Jul 5, 2018 in Java by Daisy
• 8,120 points
616 views
0 votes
2 answers

C++ performance vs. Java/C#

The overhead of interpreting code is much higher than ...READ MORE

Dec 27, 2018 in Java by iangregor
• 300 points
996 views
0 votes
1 answer

Hibernate show real SQL

If you want to see the SQL ...READ MORE

Jul 5, 2018 in Java by Sushmita
• 6,910 points
834 views
0 votes
2 answers

How to left pad a string with zero in java?

String paddedString = org.apache.commons.lang.StringUtils.leftPad("129018", 10, "0") the second ...READ MORE

Aug 31, 2018 in Java by Sushmita
• 6,910 points
2,878 views
0 votes
1 answer

How to pretty print XML from Java?

Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //initialize StreamResult ...READ MORE

Jul 4, 2018 in Java by Akrati
• 3,190 points
1,691 views
0 votes
1 answer

java.lang.UnsupportedClassVersionError: Bad version number in .class file. How to solve this?

I've learned that error messages like this ...READ MORE

Jul 4, 2018 in Java by Annie
• 240 points
741 views
0 votes
1 answer

What is the equivalent of the C++ Pair<L,R> in Java?

In a thread on comp.lang.java.help, Hunter Gratzner ...READ MORE

Jul 4, 2018 in Java by Rishabh
• 3,620 points
835 views
0 votes
1 answer

How to tell Jackson to ignore a field during serialization if its value is null?

To suppress serializing properties with null values ...READ MORE

Jul 4, 2018 in Java by Rishabh
• 3,620 points
6,846 views