Most viewed questions in Java

+1 vote
1 answer

How to tell the Maven to use the latest version of dependency in Java?

If you always want to use the ...READ MORE

Jun 26, 2018 in Java by Sushmita
• 6,910 points
14,670 views
0 votes
1 answer

Wait until all jQuery Ajax requests are done?

You may need to run certain code ...READ MORE

May 30, 2022 in Java by gaurav
• 23,260 points
14,641 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,528 views
0 votes
2 answers

Include all the jars in a directory within the Java classpath

Just use lib/*   not lib/*.jar   That's the ...READ MORE

Apr 6, 2019 in Java by anonymous
14,290 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

edited Mar 4, 2022 by Sarfaraz 14,187 views
0 votes
2 answers

How to round a double to 2 decimal places?

double value = 200.3456; System.out.printf("Value: %.2f", value); You can ...READ MORE

Dec 11, 2018 in Java by Sushmita
• 6,910 points
13,923 views
0 votes
1 answer

How to set base url for rest in spring boot?

Hello @kartik, Set it up in your application.yml ...READ MORE

May 22, 2020 in Java by Niroj
• 82,880 points
13,801 views
+1 vote
2 answers

Non-static variable cannot be referenced from a static context. Explain?

class Program { int count ...READ MORE

Sep 28, 2019 in Java by anonymous
13,601 views
+2 votes
3 answers

Listing all the subclasses of a specific class in Java

Try with BurningWave core library. Here an ...READ MORE

Dec 29, 2019 in Java by anonymous
• 460 points

edited Jan 9, 2020 by anonymous 12,918 views
0 votes
1 answer

Interface variable are static and final by default. Why?

Interface variables are static because Java interfaces ...READ MORE

Jul 4, 2018 in Java by Daisy
• 8,120 points
12,584 views
0 votes
1 answer

Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio

In Android Studio 3.1, you can see ...READ MORE

Feb 17, 2022 in Java by Aditya
• 7,680 points
12,535 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,190 points
12,427 views
+1 vote
2 answers

Java: Nested Methods

public class ObjClass {     ObjClass anyMethod() ...READ MORE

Jan 19, 2020 in Java by zemiak
12,419 views
0 votes
2 answers

How do I get the size of a java.sql.ResultSet?

You could probably do rows-count. ResultSet rs = ...READ MORE

Aug 22, 2019 in Java by Sirajul
• 59,230 points
12,334 views
0 votes
1 answer

Integrate UTF-8 encoding in Java WebApp

Mostly characters äåö are not a problematic ...READ MORE

Dec 12, 2018 in Java by Sushmita
• 6,910 points
12,227 views
0 votes
2 answers

In Java, what is the best way to determine the size of an object?

I happened to find a java class "jdk.nashorn.internal.ir.debug.ObjectSizeCalculator", ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 59,230 points
12,163 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
11,999 views
0 votes
1 answer

How to get comments by given user in Facebook Graph API? Can we get list of comments made by given user?

Hii kartik, You can get the list of ...READ MORE

May 7, 2020 in Java by Niroj
• 82,880 points
11,996 views
0 votes
1 answer

Switch JPanels inside a JFrame

Instead of trying to add an remove ...READ MORE

Feb 14, 2019 in Java by developer_1
• 3,320 points
11,967 views
0 votes
1 answer

Error:java.lang.OutOfMemoryError: Java heap space in Maven

Hello @kartik, Here is the whole config that ...READ MORE

Jun 3, 2020 in Java by Niroj
• 82,880 points
11,958 views
0 votes
1 answer

@Component vs @Controller vs @Repository vs @Service annotations in Spring Framework

@Component: This marks a java class as a bean. ...READ MORE

Nov 28, 2018 in Java by code.reaper12
• 3,500 points
11,880 views
0 votes
2 answers

How to ignore exception in Java?

There is no way to basically ignore a ...READ MORE

Aug 16, 2019 in Java by Sirajul
• 59,230 points
11,862 views
0 votes
3 answers

How can I add new elements to an Array in Java

String[] source = new String[] { "a", ...READ MORE

Sep 19, 2018 in Java by Sushmita
• 6,910 points
11,420 views
0 votes
1 answer

What is the difference between Polymorphism, Overriding and Overloading?

As far as I know, the main ...READ MORE

Jun 19, 2018 in Java by scarlett
• 1,290 points
11,246 views
0 votes
1 answer

Unrecognized SSL message, plaintext connection? Exception

It is due to the fact that ...READ MORE

Feb 22, 2022 in Java by Aditya
• 7,680 points
11,236 views
0 votes
2 answers

How do we convert only the second letter of every word in a string to uppercase ?

The following code will perform your desired ...READ MORE

Aug 29, 2018 in Java by curious
• 560 points
11,223 views
0 votes
1 answer

How to set margins in a LinearLayout programmatically?

LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = ...READ MORE

Dec 20, 2018 in Java by Daisy
• 8,120 points
11,204 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,068 views
0 votes
1 answer

What is Eclipse Clean Mode ?

What it does: if set to "true", any ...READ MORE

Jan 11, 2019 in Java by developer_1
• 3,320 points
11,067 views
0 votes
1 answer

Trusting all certificates using HttpClient over HTTPS

Note: Do not implement this in production ...READ MORE

Jun 25, 2018 in Java by Rishabh
• 3,620 points
10,937 views
0 votes
2 answers

How can we add an image to a JPanel?

If you are using JPanels, then are ...READ MORE

Sep 20, 2018 in Java by Daisy
• 8,120 points
10,910 views
0 votes
1 answer

How to resolve the error: could not find or load main class?

If you are getting error: could not ...READ MORE

May 28, 2018 in Java by Parth
• 4,630 points
10,809 views
0 votes
1 answer

window.location.href and window.open () methods in JavaScript

To answer your question, first of all, ...READ MORE

Feb 9, 2022 in Java by Rahul
• 9,670 points
10,716 views
0 votes
1 answer

Is there a way to mask the password from java user input that comes from Scanner class and System.out.Println()?

You can use the console class to do so. ...READ MORE

May 27, 2019 in Java by Omkar
• 69,210 points
10,701 views
0 votes
1 answer

3DES encryption/decryption in Java

Hey, its just that Base 64 encoding ...READ MORE

Nov 8, 2018 in Java by nirvana
• 3,130 points
10,596 views
0 votes
1 answer

What is a serialVersionUID and why should we use it?

Hello @kartik, SerialVersionUID is a unique identifier for each ...READ MORE

May 28, 2020 in Java by Niroj
• 82,880 points
10,497 views
0 votes
1 answer

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

May 25, 2018 in Java by geek.erkami
• 2,680 points
10,319 views
0 votes
2 answers

How can we add the local JAR files to the Maven Project in Java?

Firstly I would like to give credit ...READ MORE

Nov 5, 2018 in Java by Sushmita
• 6,910 points
10,159 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,116 views
0 votes
1 answer

Accessing Json array with Java

An org.json.JSONArray is not iterable. Here's how I process elements ...READ MORE

Jan 22, 2019 in Java by developer_1
• 3,320 points
10,026 views
+2 votes
10 answers

Convert Java Byte Array - String - Byte Array

Character Stream Vs Byte Stream Character oriented are ...READ MORE

Sep 25, 2018 in Java by carldivin
• 180 points
9,808 views
0 votes
1 answer

How do I implement a HttpURLConnection using a Proxy ?

Since java 1.5 you can also pass ...READ MORE

Dec 10, 2018 in Java by Sushmita
• 6,910 points
9,694 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,635 views
+2 votes
2 answers

How to connect to Oracle using Service Name instead of SID?

HII.. I hope this information may help you- Thin-style ...READ MORE

Sep 29, 2020 in Java by SRI
9,573 views
0 votes
1 answer

The specified child already has a parent. You must call removeView() on the child's parent first (Android)

The error message says what You should ...READ MORE

Feb 16, 2022 in Java by Aditya
• 7,680 points
9,503 views
0 votes
1 answer

Play MP3 files usng Java API

I don't believe the java AudioStream class ...READ MORE

May 10, 2018 in Java by Rishabh
• 3,620 points
9,231 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,186 views
0 votes
1 answer

Converting ISO 8601-compliant String to java.util.Date

Unfortunately, the time zone formats available to SimpleDateFormat (Java ...READ MORE

Nov 27, 2018 in Java by Daisy
• 8,120 points

edited Oct 7, 2021 by Sarfaraz 9,169 views
0 votes
1 answer

IllegalArgumentException: navigation destination xxx is unknown to this NavController

Hello @kartik, Check currentDestination before calling navigate might be helpful. For ...READ MORE

May 26, 2020 in Java by Niroj
• 82,880 points
9,100 views
0 votes
1 answer

What causes java.lang.reflect.InvocationTargetException

The exception is thrown if InvocationTargetException - if ...READ MORE

Jun 20, 2018 in Java by Rishabh
• 3,620 points
8,721 views