Most voted questions in Java

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,888 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
889 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
1,010 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,942 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
458 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,357 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,536 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,583 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
862 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,183 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

Aug 29, 2018 in Java by Daisy
• 8,120 points
1,346 views
0 votes
1 answer

parse int value from a char

Check Character.getNumericValue(char). String element = "el7"; int x = Character.getNumericValue(element.charAt(2)); System.out.println("x=" ...READ MORE

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

get a class instance of generics type T

The short answer is, that there is ...READ MORE

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

The best way to filter a Java Collection?

 this problem is solved using streams and ...READ MORE

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

Get parameters from the URL with JSP

To delete the subject record with its ...READ MORE

May 29, 2018 in Java by Parth
• 4,630 points
3,159 views
0 votes
2 answers

Java Environment Variables

--- To set java path --- There are ...READ MORE

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

Encode String to UTF-8

String objects in Java use the UTF-16 ...READ MORE

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

Use of Static Keyword in a Class

It means that there is only one ...READ MORE

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

How to implement constants in java

Here is the solution- public static final TYPE ...READ MORE

May 28, 2018 in Java by sophia
• 1,400 points
448 views
0 votes
1 answer

Why java have transient fields?

Variables may be marked transient to indicate that they ...READ MORE

May 28, 2018 in Java by Daisy
• 8,120 points
833 views
0 votes
1 answer

How to run the JAR files in windows?

Following are the steps to run the ...READ MORE

May 28, 2018 in Java by Parth
• 4,630 points
916 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,910 views
0 votes
1 answer

How does contains() method work in evaluating objects?

Generally you should also override hashCode() each time you ...READ MORE

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

Importing classes in JSP

Use Page Directive to import a Class ...READ MORE

May 25, 2018 in Java by Rishabh
• 3,620 points
26,915 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,375 views
0 votes
1 answer

NoClassDefFoundError in Java

Can’t tell you the exact reason as ...READ MORE

May 25, 2018 in Java by v.liyyah
• 1,300 points
2,311 views
0 votes
2 answers

How can we add leading zeros to the number in Java?

From Java 1.5 you can use the String.format method. ...READ MORE

Aug 26, 2019 in Java by Sirajul
• 59,230 points
4,706 views
0 votes
2 answers

When and how to use Super() keyword in Java?

super() is used to call immediate parent. super() can be ...READ MORE

Jul 9, 2018 in Java by Sushmita
• 6,910 points
1,611 views
0 votes
1 answer

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

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

How to calculate method execution time in Java ?

Use the following code : new Timer(""){{ ...READ MORE

May 25, 2018 in Java by Rishabh
• 3,620 points
1,540 views
0 votes
2 answers

How can I convert byte array into hex string in Java?

public static String byteArrayToHex(byte[] a) { ...READ MORE

Aug 29, 2019 in Java by Sirajul
• 59,230 points
2,622 views
0 votes
1 answer

What is the difference between package private, public, protected?

Modifier Class Package Subclass World Public Y Y Y Y Protected Y Y Y N No modifier Y Y N N private Y N N N   Public: Any package, any class accessibility is ...READ MORE

May 24, 2018 in Java by Parth
• 4,630 points
1,390 views
0 votes
1 answer

What is the 'instanceof' operator used for in Java?

It's an operator that returns true if ...READ MORE

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

Overloaded method for null in Java

The method invoked here will be the ...READ MORE

May 23, 2018 in Java by code.reaper12
• 3,500 points
757 views
0 votes
1 answer

Working of post increment operator in Java

Well, I think the confusion is because ...READ MORE

May 23, 2018 in Java by geek.erkami
• 2,680 points
594 views
0 votes
2 answers

How to get input from user using System.console()?

Scanner in = new Scanner(System.in); int i = ...READ MORE

Aug 2, 2018 in Java by Sushmita
• 6,910 points
824 views
0 votes
2 answers

How can I split the String with any whitespace character as delimiter?

String string = "Today's weather"; String[] arrayOfString = ...READ MORE

Aug 23, 2019 in Java by Sirajul
• 59,230 points
837 views
0 votes
3 answers

Does Java support Default Parameters?

You can try this with method overloading. void ...READ MORE

Sep 21, 2018 in Java by Sushmita
• 6,910 points
6,625 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,424 views
0 votes
2 answers

Avoiding != null statements

public String getPostcode(Person person) { ...READ MORE

Aug 20, 2018 in Java by Daisy
• 8,120 points
518 views
0 votes
3 answers

Change date format in a Java string

The reason for the inaccuracy is because ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
2,884 views
0 votes
3 answers

How to clear the console in Java?

import java.io.IOException; public class chkClearScreen {     public static void ...READ MORE

Aug 26, 2020 in Java by ItsJustRaja
35,423 views
0 votes
1 answer

How can we resolve ClassNotFoundException in Java?

Your classpath is broken. Depending on how you ...READ MORE

May 22, 2018 in Java by Akrati
• 3,190 points
1,037 views
0 votes
2 answers

What is a StackOverflow Error

stackoverflow error – StackOverflow Error in Java. This error is thrown to ...READ MORE

Aug 29, 2020 in Java by Pistle
• 1,000 points
1,852 views
0 votes
1 answer

How to remove ‘char’ from a String?

Hi...here you can try using the overloaded ...READ MORE

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

How to convert ArrayList<String> to String[] in Java

Try this:  String[] strArray = arrayList.toArray(new Str ...READ MORE

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

Which is the best GUI designer for Eclipse?

Windows Builder Pro is the best GUI ...READ MORE

May 21, 2018 in Java by Akrati
• 3,190 points
1,621 views
0 votes
2 answers

How can we remove an element from an array in Java?

You can use ArrayUtils class remove method which ...READ MORE

May 24, 2018 in Java by UshaK
2,398 views
0 votes
2 answers

How do I use a Priority Queue

Use the constructor overload which takes a Comparator<? ...READ MORE

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

How can I make the return type of a method generic?

First of all, define callFriend: public <T extends ...READ MORE

May 19, 2018 in Java by sharth
• 3,370 points
630 views