Latest questions in Java

0 votes
2 answers

How can I sort values of a Map in Java using its key

Assuming TreeMap is not good for you ...READ MORE

Oct 10, 2018 in Java by Sushmita
• 6,910 points
933 views
0 votes
1 answer

How to split Strings by space in Java ?

You can use split() method. str = "Hello ...READ MORE

May 16, 2018 in Java by sharth
• 3,370 points
1,333 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

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,329 views
0 votes
1 answer

How to read and write on an excel files?

Follow these steps: Write: public class User { ...READ MORE

May 15, 2018 in Java by Rishabh
• 3,620 points
1,288 views
0 votes
2 answers

How do i create generic array in Java

as first tip you cannot assign value ...READ MORE

Feb 13, 2020 in Java by sama
16,906 views
+2 votes
10 answers

Convert Java Byte Array - String - Byte Array

Character Stream Vs Byte Stream Character oriented are ...READ MORE

Sep 25, 2018 in Java by carldivin
• 180 points
9,899 views
+4 votes
11 answers

How to import a jar file in Eclipse?

Click on File > Import. The Import ...READ MORE

Aug 23, 2018 in Java by Daisy
• 8,120 points
352,968 views
0 votes
2 answers

How to call one constructor from another in Java?

public class Cons { public static Cons ...READ MORE

Jul 24, 2018 in Java by Akrati
• 3,190 points
1,328 views
0 votes
1 answer

How does omitting curly braces in Java program, effect the code ?

Using braces makes the code more maintainable ...READ MORE

May 14, 2018 in Java by Rishabh
• 3,620 points
2,727 views
0 votes
1 answer

What is Java Enterprise Edition ?

Is Java EE just a specification? What ...READ MORE

May 14, 2018 in Java by Rishabh
• 3,620 points
722 views
0 votes
1 answer

How to get the number of digits in an int?

You can find out the length of ...READ MORE

May 14, 2018 in Java by Akrati
• 3,190 points
742 views
0 votes
2 answers

How to convert byte array to String and STring to byte array?

The best possible way of conversion between byte[] and String is to ...READ MORE

Aug 22, 2019 in Java by Sirajul
• 59,230 points
3,076 views
0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

May 11, 2018 in Java by Rishabh
• 3,620 points
1,338 views
0 votes
2 answers

Result of character addition in Java

Binary arithmetic operations on char and byte ...READ MORE

Aug 22, 2019 in Java by Sirajul
• 59,230 points
4,125 views
0 votes
1 answer

How to reverse an int array in Java?

for(int i = 0; i < Data.length ...READ MORE

May 11, 2018 in Java by Akrati
• 3,190 points
779 views
0 votes
1 answer

Can Abstract Class have a Constructor?

Yes, an abstract class can have a ...READ MORE

May 11, 2018 in Java by sharth
• 3,370 points
920 views
0 votes
1 answer

What is ArrayIndexOutOfBoundsException ?

If You check System.out.print(names.length); you will get 3 ...READ MORE

May 11, 2018 in Java by sharth
• 3,370 points
781 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

May 11, 2018 in Java by Parth
• 4,630 points
1,626 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

May 11, 2018 in Java by code.reaper12
• 3,500 points
873 views
0 votes
2 answers

Fetch list of in-between dates using Java

java.time Package The new java.time.package in Java 8 incorporates ...READ MORE

Aug 21, 2019 in Java by Sirajul
• 59,230 points
5,413 views
0 votes
1 answer

How do I join 2 lists

This is not a simpler method, but ...READ MORE

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

Get all the permutations of a string in Java

You could use recursion to do this.  Try ...READ MORE

Aug 21, 2019 in Java by Sirajul
• 59,230 points
1,870 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

May 10, 2018 in Java by Rishabh
• 3,620 points
1,045 views
0 votes
1 answer

Play MP3 files usng Java API

I don't believe the java AudioStream class ...READ MORE

May 10, 2018 in Java by Rishabh
• 3,620 points
9,267 views
0 votes
2 answers

How to round up a value to 2 decimal places?

double d = 2.34568; DecimalFormat f = new ...READ MORE

Aug 30, 2018 in Java by Sushmita
• 6,910 points
1,065 views
+1 vote
3 answers

How to convert a List to an Array in Java?

Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE

Aug 7, 2018 in Java by Akrati
• 3,190 points
892 views
0 votes
2 answers

Exception found while using Thread.sleep() and wait() in Java

A simpler way to wait is to ...READ MORE

Aug 13, 2018 in Java by samarth295
• 2,220 points
8,756 views
0 votes
2 answers

When to use LinkedList and ArrayList in Java?

ArrayList is what you want. LinkedList is almost always a ...READ MORE

Dec 11, 2018 in Java by Sushmita
• 6,910 points
868 views
0 votes
2 answers

Understand working of String Builder and String Buffer

Basically, StringBuffer methods are synchronized while StringBuilder ...READ MORE

Aug 29, 2018 in Java by Sushmita
• 6,910 points
841 views
0 votes
1 answer

Converting String and Float Data-types

Using Java’s Float class. float f = Float.parseFloat("25"); String s = ...READ MORE

May 9, 2018 in Java by developer_1
• 3,320 points
600 views
0 votes
2 answers

Is there a destructor in Java?

try (BufferedReader br = new BufferedReader(new FileReader(path))) ...READ MORE

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

What does Java option -Xmx stand for?

-Xmxn: It specifies the maximum size, in bytes, ...READ MORE

May 9, 2018 in Java by sharth
• 3,370 points
1,422 views
0 votes
1 answer

Why the main() method in Java is always static?

As you might know, static here is ...READ MORE

May 9, 2018 in Java by geek.erkami
• 2,680 points
1,908 views
0 votes
1 answer

Need for finalize() in Java

finalize() is a method called by the ...READ MORE

May 9, 2018 in Java by code.reaper12
• 3,500 points
526 views
+1 vote
3 answers

Copy Java Array and make a duplicate of it

int[] a = {1,2,3,4,5}; int[] b = Arrays.copyOf(a, ...READ MORE

Aug 30, 2018 in Java by Sushmita
• 6,910 points
1,392 views
0 votes
1 answer

Implement Tree(Datastructure) in Java

I wrote a small "TreeMap" class based ...READ MORE

May 9, 2018 in Java by sharth
• 3,370 points
1,249 views
0 votes
1 answer

Perform "Switch-case" on String in Java

Switches based on integers can be optimized ...READ MORE

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

In which class is the "length" property of array defined ?

It's defined in the Java language specification: The members ...READ MORE

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

Convert String type to byte[] in Java

Try using String.getBytes(). It returns a byte[] ...READ MORE

May 8, 2018 in Java by Rishabh
• 3,620 points
591 views
0 votes
3 answers

Adding text to a file using Java

try { final Path ...READ MORE

Sep 6, 2018 in Java by Sushmita
• 6,910 points
1,123 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,605 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,719 views
0 votes
1 answer

Difference between String.equals() and ==

Though both are used for comparison, but the ...READ MORE

May 7, 2018 in Java by geek.erkami
• 2,680 points
652 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

May 7, 2018 in Java by code.reaper12
• 3,500 points
4,296 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
858 views
0 votes
3 answers

How to convert File to Byte[] in Java?

import java.io.File; import java.nio.file.Files; File file; // ...(file is initialised)... byte[] ...READ MORE

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

Sorting an ArrayList in Java

You can easily do this by simply ...READ MORE

May 5, 2018 in Java by geek.erkami
• 2,680 points
1,962 views
0 votes
1 answer

HashMap vs LinkedHashMap vs TreeMap

Hi, there is no as such difference ...READ MORE

May 5, 2018 in Java by v.liyyah
• 1,300 points
1,187 views
0 votes
2 answers

What is the use of @Override annotation in Java ? When do we use it ?

@Override annotation is used when we override ...READ MORE

Aug 14, 2019 in Java by Sirajul
• 59,230 points
3,136 views