Most answered questions in Java

0 votes
1 answer

Escaping strings in JSON

You can find a JSON library in your ...READ MORE

Oct 4, 2018 in Java by geek.erkami
• 2,680 points
23,848 views
0 votes
1 answer

How do you produce a double in Java

double num = 5; When you do this, ...READ MORE

Oct 4, 2018 in Java by anto.trigg4
• 3,440 points
583 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,370 points
6,980 views
0 votes
1 answer

Non-static method within Static method in Java

As per my knowledge, you are getting this error ...READ MORE

Sep 28, 2018 in Java by anto.trigg4
• 3,440 points
1,045 views
0 votes
1 answer

System.exit() method in Java

System.exit() is a method of System class ...READ MORE

Sep 28, 2018 in Java by code.reaper12
• 3,500 points
1,286 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 27, 2018 in Java by code.reaper12
• 3,500 points
8,703 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,120 points
2,977 views
0 votes
1 answer

What is the best Java email address validation method?

Apache Commons is generally known as a ...READ MORE

Sep 26, 2018 in Java by Parth
• 4,630 points
554 views
0 votes
1 answer

Calling remove in foreach loop in Java

To safely remove from a collection while ...READ MORE

Sep 26, 2018 in Java by sharth
• 3,370 points
8,622 views
0 votes
1 answer

Using Jackson to deserialise an array of object

First create a mapper : import com.fasterxml.jackson.databind.ObjectMapper;// in ...READ MORE

Sep 26, 2018 in Java by Sushmita
• 6,910 points
4,963 views
0 votes
1 answer

How to convert a string representation of a hex dump to a byte array using Java?

public static byte[] hexStringToByteArray(String s) { ...READ MORE

Sep 26, 2018 in Java by sharth
• 3,370 points
1,688 views
0 votes
1 answer

object references an unsaved transient instance - save the transient instance before flushing

You should add cascade="all" (if using xml) ...READ MORE

Sep 26, 2018 in Java by Parth
• 4,630 points
34,325 views
0 votes
1 answer

How can we get the current location in Android?

First you need to define a LocationListener to handle ...READ MORE

Sep 25, 2018 in Java by Parth
• 4,630 points
753 views
0 votes
1 answer

Increasing the JVM memory using command line

You can adjust your JVM memory needs by ...READ MORE

Sep 25, 2018 in Java by geek.erkami
• 2,680 points
461 views
0 votes
1 answer

Unescaping HTML character entities in Java

I guess you can use this function: StringEscapeUtils.unescapeH ...READ MORE

Sep 25, 2018 in Java by anto.trigg4
• 3,440 points
391 views
0 votes
1 answer

notify() vs. notifyAll() in Java

notify() is used to wake any thread in the wait ...READ MORE

Sep 20, 2018 in Java by code.reaper12
• 3,500 points
1,779 views
0 votes
1 answer

Fetching screen resolution using Java

You can fetch the screen resolution using the Toolkit.getScreenSize() method ...READ MORE

Sep 20, 2018 in Java by anto.trigg4
• 3,440 points
4,332 views
0 votes
1 answer

revalidate() vs repaint() in Java Swing

You need to call repaint() and revalidate() both in order ...READ MORE

Sep 20, 2018 in Java by code.reaper12
• 3,500 points
10,257 views
0 votes
1 answer

Array indexOf() in Java

You can use this indexOf() method through Arrays utility class. If the ...READ MORE

Sep 20, 2018 in Java by geek.erkami
• 2,680 points
2,673 views
0 votes
1 answer

Various Advice in Spring AOP

Below are the various advices available in AOP: Before: These types ...READ MORE

Sep 12, 2018 in Java by geek.erkami
• 2,680 points
1,122 views
0 votes
1 answer

@RequestMapping annotation in Java Spring

The @RequestMapping annotation in Spring Framework is ...READ MORE

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

Spring AOP vs AspectJ AOP

Well, below I have listed down few ...READ MORE

Sep 10, 2018 in Java by v.liyyah
• 1,300 points
1,170 views
0 votes
1 answer

@Qualifier annotation in Spring Framework

When you create more than one bean ...READ MORE

Sep 10, 2018 in Java by code.reaper12
• 3,500 points
1,561 views
0 votes
1 answer

Executing commands with parameters in Java

Try using the below command: Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", ...READ MORE

Sep 5, 2018 in Java by geek.erkami
• 2,680 points
2,720 views
0 votes
1 answer

Java anonymous code blocks

The anonymous code blocks in Java are ...READ MORE

Sep 5, 2018 in Java by anto.trigg4
• 3,440 points
1,429 views
0 votes
1 answer

How to download a file from spring controllers?

@RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) public void ...READ MORE

Sep 4, 2018 in Java by code.reaper12
• 3,500 points
2,622 views
0 votes
1 answer

SuppressWarnings (“unchecked”) in Java

@SuppressWarnings("unchecked") is used when Java generics just don't ...READ MORE

Sep 4, 2018 in Java by anto.trigg4
• 3,440 points
8,362 views
0 votes
1 answer

Bean life cycle in Spring Bean Factory Container

Bean life cycle in Spring Bean Factory ...READ MORE

Aug 30, 2018 in Java by code.reaper12
• 3,500 points
2,860 views
0 votes
1 answer

Add jars to maven 2 build class path without installing them?

wn voteA quick&dirty batch solution (based on Alex's answer): libs.bat @ECHO ...READ MORE

Aug 30, 2018 in Java by samarth295
• 2,220 points
950 views
0 votes
1 answer

Constructor injection vs Setter injection in Spring Framework

Here, I have listed down few differences. ...READ MORE

Aug 30, 2018 in Java by anto.trigg4
• 3,440 points
2,995 views
0 votes
1 answer

Generate UML diagrams from Java code?

You could also give the netbeans UML ...READ MORE

Aug 30, 2018 in Java by samarth295
• 2,220 points
851 views
0 votes
1 answer

How to calculate the interval between 2 dates

The following code might be helpful: public static ...READ MORE

Aug 29, 2018 in Java by bug_seeker
• 15,520 points
695 views
0 votes
1 answer

Enums be subclassed to add new elements?

I suggest you take the other way ...READ MORE

Aug 29, 2018 in Java by Parth
• 4,630 points
472 views
0 votes
1 answer

Simple HTTP server in Java using only Java SE API

You can write a pretty simple embedded Jetty Java ...READ MORE

Aug 29, 2018 in Java by Parth
• 4,630 points
1,660 views
+1 vote
1 answer

How do I do a HTTP GET?

If you don't want to use external ...READ MORE

Aug 28, 2018 in Java by Neha
• 6,300 points
437 views
0 votes
1 answer

How to create a temporary directory/folder in java?

If you are using JDK 7 use ...READ MORE

Aug 28, 2018 in Java by Frankie
• 9,830 points
6,105 views
+1 vote
1 answer

How to calculate days between two dates?

You are making some conversions with your ...READ MORE

Aug 28, 2018 in Java by Frankie
• 9,830 points
2,607 views
0 votes
1 answer

Spring configuration file

A Spring configuration file is an XML ...READ MORE

Aug 28, 2018 in Java by v.liyyah
• 1,300 points
6,139 views
0 votes
1 answer

Types of IOC containers in Spring Framework

There are basically two types of IOC ...READ MORE

Aug 28, 2018 in Java by misc.edu04
• 1,450 points
25,295 views
0 votes
1 answer

Retrieve a file from a server via SFTP

Below is an example using Apache Common ...READ MORE

Aug 28, 2018 in Java by samarth295
• 2,220 points
682 views
0 votes
1 answer

Why is the Scanner skipping nextLine() after using next() or nextFoo()

public static void main(String[] args) { ...READ MORE

Aug 28, 2018 in Java by samarth295
• 2,220 points
1,437 views
0 votes
1 answer

What are the Foreign key constraints in Android using SQLite

You can use, Foreign key constraints with ...READ MORE

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

Removing an Integer from a List<Integer> in Java

In Java, the method best suiting your argument ...READ MORE

Aug 24, 2018 in Java by anonymous
1,310 views
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
407 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
546 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,452 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
578 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
628 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,326 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,025 views