Latest questions in Java

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,322 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
517 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,485 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
663 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,148 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,219 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,013 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
461 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
443 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
822 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
905 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,889 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
810 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,851 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,360 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,302 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,675 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,588 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
738 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,531 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,617 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,378 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
829 views
+7 votes
16 answers

Unable to resolve this error: "javac is not recognized as an internal or external command"

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

May 23, 2018 in Java by Rishabh
• 3,620 points
458,014 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
752 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
578 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
805 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
813 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,598 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,382 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
500 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,856 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,362 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,029 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,673 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,841 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
525 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
766 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,604 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,373 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
770 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
624 views
0 votes
2 answers

Explain the functionality of Math.random() method.

You can use java.util.Random class. int myNumber = ...READ MORE

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

How can I solve java.lang.NoClassDefFoundError in Java?

NoClassDefFoundError means that the class is present ...READ MORE

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

Convert comma-separated String to ArrayList?

List<String> alist = Arrays.asList(str.split("\\s*,\\s*")); The above code splits ...READ MORE

May 17, 2018 in Java by sharth
• 3,370 points
2,820 views
0 votes
2 answers

Does Java allow to create static classes?

Java has "static nested classes", but they ...READ MORE

Sep 5, 2018 in Java by Sushmita
• 6,910 points
935 views
0 votes
1 answer

How to retrieve current stack trace?

Yes, in Java we do have a ...READ MORE

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

Replacing a String with a character

Yes, you are missing out on a ...READ MORE

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

I'm getting following error, while i'm running code in windows xp service pack 3 with JDK 6 version.

Till you send the code, I would ...READ MORE

May 16, 2018 in Java by Meci Matt
• 9,460 points
2,273 views
0 votes
1 answer

How can I get Key from their respective Values

public class NewClass1 { ...READ MORE

May 16, 2018 in Java by Parth
• 4,630 points
495 views