Most viewed questions in Java

0 votes
1 answer

What is truncation in Java?

In Java, truncation refers to the process ...READ MORE

Nov 2, 2023 in Java by anonymous
• 3,320 points
1,036 views
0 votes
1 answer

How to connect Java to MySql Database?

Make sure you have the MySQL jdbc ...READ MORE

Sep 30, 2019 in Java by Shyam
1,033 views
0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

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

How to handle infinite loop in Java?

You can simply add a increment statement ...READ MORE

Nov 22, 2018 in Java by Anoop
1,030 views
0 votes
1 answer

Gracefully stopping a java thread

The preferable way will be to use a ...READ MORE

Aug 21, 2018 in Java by anto.trigg4
• 3,440 points
1,030 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,030 views
0 votes
2 answers

Java string to date conversion

We can convert String to Date in java using parse() method ...READ MORE

Dec 29, 2020 in Java by Nikita
1,024 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,022 views
0 votes
1 answer

What is the difference between static and inner class?

An inner class, cannot be static, so ...READ MORE

Jul 11, 2018 in Java by sophia
• 1,400 points
1,019 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,018 views
0 votes
1 answer

Why “non-static method cannot be referenced from a static context”?

You can't call something that doesn't exist. ...READ MORE

Oct 17, 2018 in Java by sharth
• 3,370 points
1,015 views
0 votes
1 answer

Bean Scopes in Java Spring

According to my knowledge, the Spring Framework ...READ MORE

Jul 4, 2018 in Java by geek.erkami
• 2,680 points
1,014 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,011 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,011 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
1,005 views
+1 vote
1 answer

How to generate a class at runtime in Java?

Yes: you can do it with Burningwave ...READ MORE

Mar 16, 2020 in Java by Roberto
• 460 points

edited Apr 14, 2020 by Roberto 1,005 views
0 votes
1 answer

How to set a timer in Java?

To work on timer in java, you ...READ MORE

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

Which Java GUI framework we should refer?

If you are working on Desktop Application, ...READ MORE

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

How can I create an executable JAR with dependencies using Maven?

<build> <plugins> <plugin> ...READ MORE

Apr 26, 2018 in Java by sophia
• 1,400 points
1,003 views
0 votes
1 answer

Remotely debugging JVM using Java command line

In order to use JAVA_OPT you need ...READ MORE

Jun 19, 2018 in Java by 93.lynn
• 1,600 points
1,002 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
1,001 views
+12 votes
3 answers

How do I set or change the PATH system variable?

First make sure you have installed JDK ...READ MORE

Aug 28, 2018 in Java by slayer
• 29,350 points
1,000 views
0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

Sep 5, 2018 in Java by Sushmita
• 6,910 points
1,000 views
0 votes
2 answers

C++ performance vs. Java/C#

The overhead of interpreting code is much higher than ...READ MORE

Dec 27, 2018 in Java by iangregor
• 300 points
998 views
0 votes
2 answers

How to initialize multi-dimensional array in java?

a multidimensional array can define an array ...READ MORE

Mar 18, 2019 in Java by monica jesvina
995 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
995 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
994 views
0 votes
1 answer

Annotation wiring in Spring

By default, Annotation wiring is not turned ...READ MORE

Jul 4, 2018 in Java by code.reaper12
• 3,500 points
993 views
0 votes
2 answers

Can the size of dynamic array be changed?

import java.util.List; import java.util.ArrayList; import java.util.Random; public class A ...READ MORE

Aug 31, 2018 in Java by Sushmita
• 6,910 points
993 views
+1 vote
2 answers

How to generate random integers within specific range in Java?

You can achieve that concisely in Java: Random ...READ MORE

Jul 25, 2018 in Java by samarth295
• 2,220 points
992 views
+1 vote
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

Jun 26, 2018 in Java by scarlett
• 1,290 points
990 views
0 votes
2 answers

How to create a 2-D array in java?

int[][] multi = new int[5][]; multi[0] = new ...READ MORE

Jul 16, 2018 in Java by Daisy
• 8,120 points
990 views
0 votes
1 answer

USing Java App to create Windows Service

Apache Commons Daemon is a good alternative. It ...READ MORE

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

Eclipse Oxygen fails to start

I think you need to make some ...READ MORE

Jun 7, 2018 in Java by code.reaper12
• 3,500 points
989 views
0 votes
1 answer

Generate 10 fibonacci numbers.

The placement of logic is wrong that ...READ MORE

Nov 21, 2018 in Java by Nabarupa
987 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
986 views
+1 vote
2 answers

What is an Object?

Hey @preetiagarwal, your description is an answer ...READ MORE

Dec 24, 2018 in Java by Priyaj
• 58,090 points
985 views
0 votes
1 answer

'mvn' is not recognized as an internal or external command, operable program or batch file

 While I was solving this problem, the ...READ MORE

Feb 17, 2022 in Java by Aditya
• 7,680 points
983 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

Angular: conditional class with *ngClass

For your information, the latest Angular version ...READ MORE

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

How to append text to an existing file in Java?

Java 7+ If you just need to do ...READ MORE

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

edited Jul 6, 2023 by Khan Sarfaraz 975 views
0 votes
0 answers

Page Redirect after X seconds wait using JavaScript

After displaying an error notice, I need to redirect to a specified URL after 5 seconds.  First, I utilized Javascript as seen below. document.ready(window.setTimeout(location.href = "https://www.google.co.in",5000)); However, it is not ...READ MORE

Sep 28, 2022 in Java by Nicholas
• 7,760 points
971 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
970 views
0 votes
2 answers

How to break the nested loop in Java?

You can use break with a label for the ...READ MORE

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

How to get the current date/time in Java?

It depends on what form of date/time ...READ MORE

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

How to install and configure JDK8 on Windows 10

Hey @Henna, Go to this page  Accept the license ...READ MORE

Feb 28, 2019 in Java by Kalgi
968 views
0 votes
2 answers

what is the best way to convert an ArrayList to a String

You could probably use the Joiner class ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 59,230 points
967 views
0 votes
0 answers

How to populate a ListView using an ArrayList?

I want to populate the data coming ...READ MORE

Jun 30, 2018 in Java by misc.edu04
• 1,450 points
960 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

Apr 19, 2018 in Java by Rishabh
• 3,620 points
957 views
0 votes
1 answer

Sorted array is being processed faster than unsorted array. Why is it so ?

What is Branch Prediction? Consider a railroad junction: Image by ...READ MORE

Apr 18, 2018 in Java by Rishabh
• 3,620 points
955 views