Trending questions in Java

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
412 views
0 votes
3 answers

How to sort an array in java?

import java.util.Arrays; public class Sort { ...READ MORE

Aug 24, 2018 in Java by Parth
• 4,630 points
882 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
763 views
0 votes
2 answers

Remove duplicate elements from an ArrayList in Java

List<String> al = new ArrayList<>(); // add elements ...READ MORE

Jul 26, 2018 in Java by Sushmita
• 6,910 points
1,253 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
998 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
368 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,120 points
546 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
997 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
575 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
527 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,630 points
1,288 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
644 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,630 points
779 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
718 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
453 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,630 points
2,717 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,242 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
928 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,910 points
729 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,124 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
480 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
778 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,263 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,325 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,910 points
1,100 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,600 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,181 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,258 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,120 points
1,478 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,248 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
939 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
616 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
650 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
686 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
676 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,910 points
497 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
790 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
535 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,910 points
729 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,630 points
1,223 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,630 points
1,220 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
981 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,527 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
978 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,120 points
757 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,910 points
842 views
0 votes
1 answer

What is ?: this operator called in java ? how dose it function?

? :  is the Conditional operator and is ...READ MORE

Jun 11, 2018 in Java by sophia
• 1,400 points
744 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
986 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
802 views
0 votes
2 answers

Copying Objects in Java

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

Aug 6, 2018 in Java by Sushmita
• 6,910 points
506 views