Trending questions in Java

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
72 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
20 views
0 votes
1 answer

How can we handle the javax.net.ssl.SSLHandshakeException?

import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import java.io.OutputStream; // ...READ MORE

Oct 10, 2018 in Java by Daisy
• 8,050 points
149 views
0 votes
1 answer

Static methods can't be abstract in Java

Well, Java doesn't allow this because of ...READ MORE

Oct 12, 2018 in Java by v.liyyah
• 1,300 points
59 views
+2 votes
1 answer

What is the meaning of "this" keyword in Java?

public class MyThisTest { private int ...READ MORE

Oct 10, 2018 in Java by Daisy
• 8,050 points
57 views
0 votes
1 answer

Java equals() vs Arrays.equals()

Here, array1.equals(array2)meansarray1 == array2 That is, it checks whether ...READ MORE

Oct 11, 2018 in Java by code.reaper12
• 3,450 points
55 views
0 votes
1 answer

Randomly selecting an element from an array

For randomly selecting an element, java.util.Random provides ...READ MORE

Oct 11, 2018 in Java by anto.trigg4
• 3,420 points
27 views
0 votes
1 answer

How to use ThreadLocal variable

You can use a ThreadLocal variable when you have some ...READ MORE

Oct 10, 2018 in Java by code.reaper12
• 3,450 points
31 views
0 votes
1 answer

Can't access static fields in inner classes in Java

Well, the major idea behind this concept ...READ MORE

Oct 8, 2018 in Java by anto.trigg4
• 3,420 points
87 views
0 votes
1 answer

Tail call optimization in JVM

The tail call optimization in JVM is difficult ...READ MORE

Oct 9, 2018 in Java by geek.erkami
• 2,640 points
36 views
0 votes
1 answer

$ in a variable name in Java

Java compiler uses "$" symbol internally to decorate ...READ MORE

Oct 9, 2018 in Java by code.reaper12
• 3,450 points
35 views
0 votes
1 answer

Creating an instance using the class name and calling constructor

Yes: Class<?> clazz = Class.forName(className); Constructor<?> ctor = clazz.getConstructor(String.class); Object ...READ MORE

Oct 9, 2018 in Java by Daisy
• 8,050 points
45 views
0 votes
1 answer

Java's default package

Yes, technically, using the package names should ...READ MORE

Oct 8, 2018 in Java by code.reaper12
• 3,450 points
25 views
0 votes
1 answer

How to display an animated GIF?

Android actually can decode and display animated ...READ MORE

Oct 8, 2018 in Java by sharth
• 3,350 points
36 views
0 votes
1 answer

System.exit() method in Java

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

Sep 27, 2018 in Java by code.reaper12
• 3,450 points
478 views
0 votes
1 answer

revalidate() vs repaint() in Java Swing

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

Sep 19, 2018 in Java by code.reaper12
• 3,450 points
778 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,880 points
416 views
0 votes
1 answer

Autowired field pointing NULL in Spring

The field annotated @Autowired is null because ...READ MORE

Jun 6, 2018 in Java by avi
• 160 points
5,201 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,810 points
1,627 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,350 points
347 views
0 votes
1 answer

How do you produce a double in Java

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

Oct 3, 2018 in Java by anto.trigg4
• 3,420 points
28 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,420 points
592 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
65 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,350 points
191 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 27, 2018 in Java by anto.trigg4
• 3,420 points
115 views
+28 votes
3 answers

How can we set java.library.path in Eclipse?

Go into the library settings for your ...READ MORE

Jul 3, 2018 in Java by sharth
• 3,350 points
1,991 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,880 points
192 views
0 votes
1 answer

How to set Encoding in Java ?

Unfortunately, the file.encoding property has to be specified as ...READ MORE

May 29, 2018 in Java by Rishabh
• 3,540 points
5,226 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 parth295
• 4,640 points
42 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 parth295
• 4,640 points
58 views
0 votes
1 answer

Increasing the JVM memory using command line

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

Sep 24, 2018 in Java by geek.erkami
• 2,640 points
36 views
0 votes
1 answer

Unescaping HTML character entities in Java

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

Sep 24, 2018 in Java by anto.trigg4
• 3,420 points
23 views
0 votes
1 answer

Array indexOf() in Java

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

Sep 19, 2018 in Java by geek.erkami
• 2,640 points
166 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,450 points
100 views
0 votes
1 answer

Static Map initialization in Java

I would suggest you to use the ...READ MORE

May 4, 2018 in Java by Akrati
• 3,150 points
6,003 views
0 votes
2 answers

Performing HTTP POST operation in JAVA

I'm using JSON-Java to build my JSON object: JSONObject json ...READ MORE

Nov 26, 2018 in Java by Sushmita
• 6,880 points
918 views
0 votes
1 answer

@RequestMapping annotation in Java Spring

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

Sep 11, 2018 in Java by code.reaper12
• 3,450 points
237 views
0 votes
2 answers

how can we Create instance for generic type in java

private static class SomeContainer<E> { ...READ MORE

Aug 27, 2018 in Java by Sushmita
• 6,880 points
2,597 views
0 votes
2 answers

How can we assert, that a certain Exception is thrown in JUnit 4 tests?

@Test(expected = IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { ...READ MORE

Dec 10, 2018 in Java by Sushmita
• 6,880 points
98 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
266 views
0 votes
2 answers

How can I do url string decoding in java

We can use URLDecoder: URLDecoder.decode( url, "UTF-8" ); READ MORE

Dec 7, 2018 in Java by Sushmita
• 6,880 points
35 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,640 points
57 views
+12 votes
3 answers

How do I set or change the PATH system variable?

First make sure you have installed JDK ...READ MORE

Aug 28, 2018 in Java by slayer
• 29,170 points
102 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
• 67,600 points
1,600 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,450 points
81 views
0 votes
5 answers

How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

Jul 12, 2018 in Java by Daisy
• 8,050 points
128 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
205 views
0 votes
1 answer

Bean life cycle in Spring Bean Factory Container

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

Aug 29, 2018 in Java by code.reaper12
• 3,450 points
518 views
+1 vote
1 answer

What is a simple way to repeat a string in java?

From Java 11 on, there's a method String::repeat that does ...READ MORE

Aug 28, 2018 in Java by Frankie
• 9,810 points
521 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,450 points
172 views