Trending questions in Java

0 votes
1 answer

In Java, how to find out the min/max values from array of primitive data types?

import java.util.Arrays; import java.util.Collections; import org.apache.commons.lang.ArrayUtils; public class MinMaxValue { ...READ MORE

Jun 12, 2018 in Java by Daisy
• 8,140 points
1,647 views
0 votes
2 answers

How to read a text file in Java?

You can use Scanner class to read ...READ MORE

Aug 9, 2018 in Java by Parth
• 4,640 points
1,128 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,689 views
+1 vote
1 answer

What is the difference between JavaScript and Java

This quote rightly explains that 2 totally ...READ MORE

Jun 29, 2018 in Java by Daisy
• 8,140 points
784 views
0 votes
1 answer

What is the use of assert keyword in java?

Java assertion feature allows the developer to ...READ MORE

Jun 28, 2018 in Java by scarlett
• 1,290 points
860 views
0 votes
1 answer

How to get the IP address of the machine using Java?

One approach is to use NetworkInterface.getNetworkInterfaces() to get all ...READ MORE

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

How to configure Android SDK for finding JDK

Actual SETUP: OS: Windows 8.1 JDK file: jdk-8u11-windows-x64.exe ADT file: ...READ MORE

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

Date format conversion in Java

Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); Date date = ...READ MORE

Aug 13, 2018 in Java by Sushmita
• 6,920 points
1,073 views
0 votes
1 answer

Number of lines in a file in Java

I found this an efficient way in counting ...READ MORE

Jul 4, 2018 in Java by scarlett
• 1,290 points
600 views
0 votes
1 answer

How to convert s Stack trace to a String?

One can use the given method to ...READ MORE

Jun 25, 2018 in Java by sharth
• 3,370 points
1,012 views
0 votes
3 answers

Convert date object to a String

We parse the full date to time ...READ MORE

Jul 31, 2018 in Java by samarth295
• 2,220 points
1,545 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,640 points
1,197 views
0 votes
1 answer

How to stop the Thread in Java?

Use a flag, which will indicate the ...READ MORE

Jun 11, 2018 in Java by Parth
• 4,640 points
1,534 views
0 votes
1 answer

How can we get file extension in Java?

To get the file extension, we can ...READ MORE

May 8, 2018 in Java by Parth
• 4,640 points
3,000 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,187 views
0 votes
1 answer

Can a static reference be made to a non-static method

setLoanItem() isn't a static method, it's an instance ...READ MORE

Jun 26, 2018 in Java by samarth295
• 2,220 points
866 views
0 votes
1 answer

Default Constructor in Java

Well, none of these is the default ...READ MORE

Jun 19, 2018 in Java by geek.erkami
• 2,680 points
1,170 views
0 votes
1 answer

What are Daemon threads in Java?

A daemon thread is a thread that is doing ...READ MORE

Jun 29, 2018 in Java by Daisy
• 8,140 points
707 views
0 votes
1 answer

ThreadLocal variables usage in Java

public class Test { // ...READ MORE

Jun 30, 2018 in Java by code.reaper12
• 3,500 points
678 views
0 votes
2 answers

Store String inside a File using Java

We can use Apache Commons IO. It ...READ MORE

Jul 20, 2018 in Java by Sushmita
• 6,920 points
1,409 views
0 votes
1 answer

Continue Keyword in Java

continue is kind of like goto. Are you familiar ...READ MORE

Jul 3, 2018 in Java by Rishabh
• 3,620 points
493 views
0 votes
1 answer

Generating an MD5 hash?

The MessageDigest class can provide you with an instance ...READ MORE

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

How can we use java property files?

You can refer the below code: Properties properties ...READ MORE

Jun 28, 2018 in Java by Akrati
• 960 points
673 views
0 votes
1 answer

Access restriction on class error

My guess is that you are trying ...READ MORE

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

How to read text files from the Classpath in Java?

InputStream in = this.getClass().getClassLoader().getResourceAsStream("TextFile.txt"); InputStream in = this.getClass().getResourceAsStream("/TextFile.txt"); package ...READ MORE

May 8, 2018 in Java by Akrati
• 3,190 points
2,829 views
0 votes
1 answer

Formatting Double Value in Java

An alternative is to use String.format: double[] arr = ...READ MORE

May 15, 2018 in Java by Rishabh
• 3,620 points
2,500 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,140 points
1,724 views
0 votes
1 answer

How to fire and handle HTTP requests

There are 2 options you can go ...READ MORE

Jun 13, 2018 in Java by Rishabh
• 3,620 points
1,169 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,456 views
0 votes
1 answer

Is Java “pass-by-reference” or “pass-by-value”?

Think of reference parameters as being aliases ...READ MORE

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

Exception coming "android.os.NetworkOnMainThreadException"

This exception is thrown when an application ...READ MORE

Jun 6, 2018 in Java by poorvi
• 160 points
1,431 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
795 views
0 votes
1 answer

what do you mean by static block in java?

Static block is used for initializing the ...READ MORE

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

How to convert array into list in Java?

Another workaround if you use apache commons-lang: int[] ...READ MORE

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

What do you mean by object serialization ?

To serialize an object means to convert its state ...READ MORE

Jun 14, 2018 in Java by scarlett
• 1,290 points
1,035 views
0 votes
1 answer

What issues should be considered when we are overriding equals and hashCode in Java?

equals() must define an equivalent relation and ...READ MORE

Jun 21, 2018 in Java by Sushmita
• 6,920 points
731 views
0 votes
1 answer

What is the use of StringBuilder in java?

If you use String concatenation in a ...READ MORE

Jun 19, 2018 in Java by Akrati
• 960 points
803 views
0 votes
1 answer

Can we use multiline String in Java?

It is not possible directly to use Multiline ...READ MORE

Jun 19, 2018 in Java by sharth
• 3,370 points
753 views
0 votes
2 answers

How to find out current working directory in Java?

You can also use java.nio.file.Path and java.nio.file.Paths. Path ...READ MORE

Jul 31, 2018 in Java by Sushmita
• 6,920 points
1,005 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,140 points
1,543 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
1,268 views
0 votes
2 answers

How to read the files using Java?

You can use collections. try (Stream<Path> filePathStream=Files.walk(Paths.get("/home/you/Desktop"))) { ...READ MORE

Jul 10, 2018 in Java by Sushmita
• 6,920 points
1,117 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,640 points
1,452 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
1,253 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,640 points
1,423 views
0 votes
2 answers

How to convert an array to arraylist?

In Java 9 you can use: List<String> list= List.of("Hello", "World", ...READ MORE

Aug 1, 2018 in Java by samarth295
• 2,220 points
1,052 views
0 votes
2 answers

Copying Objects in Java

class DummyBean { private String dummy; ...READ MORE

Aug 6, 2018 in Java by Sushmita
• 6,920 points
764 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
1,190 views
0 votes
1 answer

What is abstract class in java?

A class that is declared with abstract ...READ MORE

Jun 11, 2018 in Java by Daisy
• 8,140 points
962 views
0 votes
2 answers

Array of Objects

You can also do : A[] a = ...READ MORE

Aug 3, 2018 in Java by sharth
• 3,370 points
811 views