Latest questions in Java

0 votes
1 answer

While using next() or nextfoo() , the upcoming nextLine() is skipped by scanner

That's because the Scanner.nextInt method does not ...READ MORE

Jun 6, 2018 in Java by mitto
• 160 points
2,628 views
0 votes
1 answer

To use JavaMail API for sending mails in Android without using the default/built-in App

ADD 3 jars found in the following ...READ MORE

Jun 6, 2018 in Java by sridhar
• 160 points
1,266 views
0 votes
1 answer

How to kill a thread in Java?

You can use a shared variable as ...READ MORE

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

How can we nicely format a floating number into String by removing unnecessary zeros?

public static String fmt(double d) { if(d ...READ MORE

Jun 6, 2018 in Java by Parth
• 4,630 points
549 views
0 votes
1 answer

Does a 32-bit byte code work in 64-bit JVM?

Yes, Java bytecode (and source code) is ...READ MORE

Jun 5, 2018 in Java by sophia
• 1,400 points
790 views
0 votes
1 answer

What is Classpath in java?

Classpath is a parameter in the Java virtual machine or ...READ MORE

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

How can we Split Java String by New Line?

If you don’t want empty lines: String.split("[\\r\\n]+") READ MORE

Aug 22, 2018 in Java by Daisy
• 8,120 points
6,831 views
0 votes
1 answer

using comparator for sorting in java

You've got two problems: 1) You're using Collections.sort (which takes ...READ MORE

Jul 6, 2018 in Java by samarth295
• 2,220 points
618 views
0 votes
1 answer

What is the difference == and equals() in Java?

Both the answers (Syntaxes) are correct. If ...READ MORE

Jun 5, 2018 in Java by Akrati
• 3,190 points
798 views
+1 vote
1 answer

How can we resolve java.lang.OutOfMemoryError in Java?

Work with smaller batches of HashMap Objects ...READ MORE

Jun 5, 2018 in Java by sharth
• 3,370 points
834 views
0 votes
1 answer

How to clone ArrayList and also clone its contents?

Iterate on the items, and clone them ...READ MORE

Jun 5, 2018 in Java by Akrati
• 3,190 points
383 views
+1 vote
2 answers

Can I convert my Java program to an .exe file?

Launch4j is a cross-platform tool for wrapping ...READ MORE

Oct 18, 2018 in Java by Sushmita
• 6,910 points
3,433 views
0 votes
4 answers

“Cannot find symbol” compilation error

The "Cannot find symbol" errors generally occur when you ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
41,890 views
0 votes
2 answers

Scanner is skipping nextLine() after using next() or nextFoo()?

use input.nextLine(); after your nextInt() function for example:- input.nextInt(); ...READ MORE

May 11, 2019 in Java by Sourav Dangi
17,097 views
0 votes
1 answer

How to resolve the java.net.ConnectException in Java?

If you are getting java.net.ConnectionException, it means ...READ MORE

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

How can we remove html tags from a string?

You can use HTML parser. This is ...READ MORE

Jun 4, 2018 in Java by sophia
• 1,400 points
3,641 views
0 votes
4 answers

How can we display an output of float data with 2 decimal places in java? Please help

You can use DecimalFormat. One way to use ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
161,134 views
0 votes
2 answers

How to sort an ArrayList of custom object by property in Java?

You can Sort using java 8 yourList.sort(Comparator.comparing(Classname::getName)); or  yourList.stream().forEach(a -> ...READ MORE

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

"No mapping found for HTTP request with URI[....] in DispatherServlet"

Your standard Spring MVC application will serve ...READ MORE

Jun 6, 2018 in Java by prasad
• 160 points
21,152 views
0 votes
1 answer

Java URL encoding of query string parameters

I would not use URLEncoder. Besides being incorrectly ...READ MORE

Jun 1, 2018 in Java by Rishabh
• 3,620 points
17,059 views
0 votes
1 answer

Decompiling Java Class Files

There are a few decompilers out there... ...READ MORE

Jun 1, 2018 in Java by Rishabh
• 3,620 points
1,006 views
0 votes
2 answers

Java enum lookup using a String

Check this...Java Enum in details READ MORE

Dec 4, 2018 in Java by allenvarna
• 540 points
721 views
+10 votes
13 answers

Default parameters of XMS and XMX in JVM

Run this code to see all the ...READ MORE

Nov 13, 2018 in Java by anonymous
397,581 views
0 votes
1 answer

How to getters and setters work in java

In Java, getter and setter are two ...READ MORE

Jun 1, 2018 in Java by Daisy
• 8,120 points
1,489 views
0 votes
1 answer

what does javabean actually means?

A JavaBean is just a standard All properties ...READ MORE

Jun 7, 2018 in Java by anonymous
478 views
0 votes
1 answer

Does python have an equivalent to Java Class.forName()?

This is found in the python standard ...READ MORE

Jun 1, 2018 in Java by Parth
• 4,630 points
1,224 views
0 votes
1 answer

How can we add JTable in JPanel with null layout?

The JPanel should have some layout manager. JTable ...READ MORE

Jun 1, 2018 in Java by Parth
• 4,630 points
1,225 views
0 votes
1 answer

How to run a JAR file in Java?

The command given below will help you ...READ MORE

Jun 1, 2018 in Java by Parth
• 4,630 points
7,171 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,425 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,910 points
4,268 views
0 votes
2 answers

Determining Class of an Object in Java

You can use: Object instance = new SomeClass(); instance.getClass().getName(); ...READ MORE

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

java.lang.OutOfMemoryError: GC overhead limit exceeded Error

This simply means that for some reason ...READ MORE

May 31, 2018 in Java by misc.edu04
• 1,450 points
4,287 views
0 votes
2 answers

Reserving space for a heap object

Run the JVM with -XX:MaxHeapSize=512m (or any big number ...READ MORE

Aug 26, 2019 in Java by Sirajul
• 59,230 points
997 views
+1 vote
1 answer

What if several ports required by tomacat server at local host are already in use

You've another instance of Tomcat already running. ...READ MORE

May 31, 2018 in Java by Akrati
• 3,190 points
5,749 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

Dec 10, 2018 in Java by Sushmita
• 6,910 points
785 views
0 votes
1 answer

How to pad an integer with zeros on the left in Java?

Use java.lang.String.format() method. String.format("%05d", number ...READ MORE

May 31, 2018 in Java by Daisy
• 8,120 points
2,086 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
11,002 views
0 votes
1 answer

Is it possible to create a memory leak with Java

Here's a good way to create a memory ...READ MORE

May 31, 2018 in Java by Parth
• 4,630 points
2,107 views
0 votes
2 answers

Connection reset : java.net.SocketException

You should check whether the client program is ...READ MORE

Sep 6, 2018 in Java by Sushmita
• 6,910 points
5,559 views
+1 vote
13 answers

How to send HTTP POST requests on Java?

With Apache HttpClient In the old days, this Apache ...READ MORE

Dec 10, 2020 in Java by Rajiv
• 8,910 points
157,512 views
0 votes
1 answer

Convert Milliseconds to “X mins, x seconds” in Java?

I wrote a function which converts milliseconds ...READ MORE

May 30, 2018 in Java by Rishabh
• 3,620 points
2,875 views
0 votes
1 answer

How to encode data using Base64 in Java?

import org.apache.commons.codec.binary.Base64; We can not use sun.* packages ...READ MORE

May 30, 2018 in Java by Sushmita
• 6,910 points
875 views
0 votes
1 answer

How to decode Base64 data in Java?

Java SE has the parser called JAXB, ...READ MORE

May 30, 2018 in Java by sharth
• 3,370 points
991 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,620 points
15,931 views
0 votes
1 answer

Unexpected result on Subtracting Times

ou've encountered a local time discontinuity: When local standard ...READ MORE

May 29, 2018 in Java by Rishabh
• 3,620 points
453 views
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

May 29, 2018 in Java by geek.erkami
• 2,680 points
3,348 views
0 votes
1 answer

Injecting property value into Spring Bean using annotations

I think you can easily perform this ...READ MORE

May 29, 2018 in Java by code.reaper12
• 3,500 points
2,523 views
0 votes
2 answers

how to increase heap size in java?

Here is how you can increase the ...READ MORE

Aug 23, 2019 in Java by Sirajul
• 59,230 points
1,569 views
0 votes
2 answers

How a static map can be initialized?

public class Test { ...READ MORE

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

How to find out a single character appears in String or not in Java?

You can use string.indexOf('s'). If the 's' is present in string, ...READ MORE

Aug 7, 2018 in Java by Sushmita
• 6,910 points
5,156 views