Most answered questions in Java

0 votes
1 answer

Static Classes In Java

Java has static nested classes but it sounds like ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,910 points

edited Jul 5, 2023 by Khan Sarfaraz 719 views
0 votes
1 answer

Can't execute jar- file: “no main manifest attribute”

First, it's kind of weird, to see ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,910 points
2,193 views
0 votes
1 answer

Download a file with Android, and showing the progress in a ProgressDialog

1. Use AsyncTask and show the download progress in ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,910 points
5,684 views
0 votes
1 answer

Converting array to list in Java

In your example, it is because you ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,910 points
727 views
0 votes
1 answer

How to install Java 8 on Mac

Oracle has a poor record for making ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,910 points
2,088 views
0 votes
1 answer

Convert ArrayList<String> to String[] array

Use like this. List<String> stockList = new ArrayList<String>(); stockList.add("stock1"); stockList.add("stock2"); String[] ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
958 views
0 votes
1 answer

Sort ArrayList of custom Objects by property

Since Date implements Comparable, it has a compareTo method just like String does. So your ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
1,247 views
0 votes
1 answer

How to round a number to n decimal places in Java?

Use setRoundingMode, set the RoundingMode explicitly to handle your issue ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points

edited Jul 6, 2023 by Khan Sarfaraz 1,392 views
0 votes
1 answer

What does “Could not find or load main class” mean?

First of all, you need to understand ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
1,001 views
0 votes
1 answer

How does the Java 'for each' loop work?

for (Iterator<String> i = someIterable.iterator(); i.hasNext();) { ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
386 views
0 votes
1 answer

Iterate through a HashMap.

Iterate through the entrySet() like so: public static void printMap(Map ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
517 views
0 votes
1 answer

How do I generate random integers within a specific range in Java?

Before Java 1.7, the standard way to ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
581 views
0 votes
1 answer

How to create create an ArrayList from array?

new ArrayList<>(Arrays.asList(array)); READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
421 views
0 votes
1 answer

What are the differences between a HashMap and a Hashtable in Java?

There are several differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
835 views
0 votes
1 answer

Avoiding NullPointerException in Java

This to me sounds like a reasonably ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
399 views
0 votes
1 answer

Why is subtracting these two times (in 1927) giving a strange result?

In TZDB 2014f, the time of the ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
289 views
0 votes
1 answer

How do I determine whether an array contains a particular value in Java?

Arrays.asList(yourArray).contains(yourValue) Warning: this doesn't work for arrays of ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
999 views
0 votes
1 answer

Initialization of an ArrayList in one line.

Actually, probably the "best" way to initialize ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
5,203 views
0 votes
1 answer

When to use LinkedList over ArrayList in Java?

LinkedList and ArrayList are two different implementations of the List ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,910 points
1,669 views
0 votes
1 answer

Is it possible to upload a file from desktop to web using Selenide?

Hi, @Nikhil, Yes it's possible to drop a ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
873 views
0 votes
1 answer

What does Animal a = (Animal) data[0]; do?

Hello @zaraaq , You can refer this for your ...READ MORE

Dec 2, 2020 in Java by Niroj
• 82,880 points
318 views
0 votes
1 answer

Logger cannot be resolved Java(570425394) Error occured

Hey, @Boopathy, Could you please post your code ...READ MORE

Dec 1, 2020 in Java by Gitika
• 65,910 points
8,866 views
0 votes
1 answer

Maven project using testng dependecy

Hello @zaraaq, First try to replace the scope ...READ MORE

Nov 25, 2020 in Java by Niroj
• 82,880 points
6,347 views
0 votes
1 answer

How to return JSON response from Flask view?

Hello, Pass the summary data to the jsonify function, which ...READ MORE

Nov 20, 2020 in Java by Niroj
• 82,880 points
2,388 views
+1 vote
1 answer

Multithreading in Java with priorities

HI, @Juan, By default, a thread inherits the priority of its parent thread. ...READ MORE

Nov 6, 2020 in Java by Gitika
• 65,910 points
2,121 views
0 votes
1 answer

Could not include JAR files

Hey, @Boopathy, Which command do you use to ...READ MORE

Oct 27, 2020 in Java by Gitika
• 65,910 points
1,491 views
0 votes
1 answer

how to serially execute selenium maven project?

Hi, @Beigi, Do check you have all the ...READ MORE

Oct 27, 2020 in Java by Nisha
434 views
0 votes
1 answer

Can i know where is java logs on centos 7?

Hey! Have you checked <user.home>/.java/deployment/log ? READ MORE

Oct 20, 2020 in Java by Kiya
2,265 views
0 votes
1 answer

Java replace : replace all charecters with space except the matched string like "test"

Hi, @jyra, You can go through this example:  String ...READ MORE

Oct 14, 2020 in Java by Gitika
• 65,910 points
620 views
0 votes
1 answer

how to get cache memory size of a application in android

To find the size of the cache ...READ MORE

Sep 4, 2020 in Java by Rajiv
• 8,910 points
2,068 views
0 votes
1 answer

How to set path if java is installed in E drive or D drive rather than c

Hello, @Amazing, It doesn't really matter where you ...READ MORE

Sep 1, 2020 in Java by Roshni
• 10,520 points

edited Jul 4, 2023 by Khan Sarfaraz 3,691 views
0 votes
1 answer

How to use an existing database with an Android application?

Hello @kartik, If you are having pre built ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
2,519 views
0 votes
1 answer

How can I get the current stack trace in Java?

Hello @kartik, Try this: Thread.currentThread().getStackTrace(); is fine if you don't ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
681 views
0 votes
1 answer

How to directly initialize a HashMap?

Hello @Kartik, In plain java 8 you also ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
977 views
0 votes
1 answer

How to add local jar files to a Maven project?

Hello @kartik, You can add local dependencies directly ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
2,082 views
0 votes
1 answer

Error:The method must override a superclass method after importing a project into Eclipse

Hello @kartik, This problem happened when I imported ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
1,610 views
0 votes
1 answer

Error:java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Hello @kartik, This error means you're trying to ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
1,392 views
0 votes
1 answer

How to avoid Java code in JSP files?

Hello @kartik, JSTL offers tags for conditionals, loops, sets, ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
478 views
0 votes
1 answer

How to get an enum value from a string value in Java?

Hello @kartik, Yes, Blah.valueOf("A") will give you Blah.A. Note that the name ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
1,757 views
0 votes
1 answer

Error:serializable class Foo does not declare a static final serialVersionUID field of type long

Hello @kartik, If you're serializing just because you ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
6,079 views
0 votes
1 answer

How to create a memory leak in Java?

Hello @kartik, A simple thing to do is ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
469 views
0 votes
1 answer

Get sub-string from text based on certain conditions/rules

Hello @laiman, You can use IsMatch function that tests whether ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
697 views
+1 vote
1 answer

if i given invalid data how to get alert in selenium using java

Hello, Here is some of the method you ...READ MORE

Jul 20, 2020 in Java by Niroj
• 82,880 points
1,018 views
0 votes
1 answer

How to Install Java in Windows system?

Hi@akhtar, You can follow the below-given steps to install ...READ MORE

Jul 7, 2020 in Java by MD
• 95,440 points
6,050 views
0 votes
1 answer

GSON fails to read/map a field with name like USERId

Hello @ RamaKrishnaRaju, You should note the Javadoc of configureMessageConverters states ...READ MORE

Jul 2, 2020 in Java by Niroj
• 82,880 points
1,781 views
0 votes
1 answer

Error:Maven Unable to locate the Javac Compiler in:

Hello @kartik, Go to Window -> Preferences... -> ...READ MORE

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

How to run a .java file from command line passing arguments in Maven?

Hello @kartik, You could run: mvn exec:exec -Dexec.args="arg1". This will ...READ MORE

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

How to install Maven artifact with sources from command line?

Hello @kartik, To download sources for your dependencies: mvn ...READ MORE

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

Error:jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

Hello @kartik, The servlet API .jar file must ...READ MORE

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

How do I configure Maven for offline development?

Hello @kartik, You have two options for this: 1.) ...READ MORE

Jun 3, 2020 in Java by Niroj
• 82,880 points
642 views