Trending questions in Java

0 votes
1 answer

How can we convert Strings to and from UTF8 byte arrays?

To convert STring to byte[]: String s = ...READ MORE

Jun 21, 2018 in Java by Akrati
• 3,190 points
1,595 views
0 votes
1 answer

What is the native keyword in Java?

The native keyword is applied to a method to ...READ MORE

Jul 16, 2018 in Java by scarlett
• 1,290 points
485 views
0 votes
1 answer

What is casting variable in java?

Casting is, taking an Object of one ...READ MORE

Jul 17, 2018 in Java by scarlett
• 1,290 points
430 views
0 votes
2 answers

How does '&&' (AND) and '||' (OR) statements work inside an IF condition ?

Short circuit here means that the second ...READ MORE

Sep 19, 2018 in Java by Sushmita
• 6,910 points
622 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
969 views
0 votes
3 answers

How to read a Text File in Java?

You can use readAllLines and the join method to ...READ MORE

Jul 28, 2018 in Java by samarth295
• 2,220 points
2,097 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
989 views
0 votes
1 answer

Injecting property value into Spring Bean using annotations

I think you can easily perform this ...READ MORE

May 29, 2018 in Java by code.reaper12
• 3,500 points
2,506 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
971 views
0 votes
1 answer

How to perform Java 256 bit AES Password Based Encryption?

/* Derive the key, given password and ...READ MORE

Jun 21, 2018 in Java by Akrati
• 3,190 points
1,490 views
0 votes
1 answer

Programmatically closing a JFrame

If you want the GUI to behave ...READ MORE

Jun 21, 2018 in Java by Parth
• 4,630 points
1,479 views
0 votes
2 answers

How to sort array in descending order

there are some traditional ways that you ...READ MORE

Jul 4, 2018 in Java by Priyaj
• 58,090 points
910 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
740 views
0 votes
2 answers

Generate an alpha-numeric string randomly

Java supplies a way of doing this ...READ MORE

Jul 18, 2018 in Java by Daisy
• 8,120 points
2,204 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
817 views
0 votes
1 answer

Hibernate show real SQL

If you want to see the SQL ...READ MORE

Jul 5, 2018 in Java by Sushmita
• 6,910 points
811 views
0 votes
1 answer

Sort a HashMap in Java

Convert hashmap to an ArrayList with a ...READ MORE

Jul 13, 2018 in Java by Daisy
• 8,120 points
487 views
0 votes
2 answers

When and how to use Super() keyword in Java?

super() is used to call immediate parent. super() can be ...READ MORE

Jul 9, 2018 in Java by Sushmita
• 6,910 points
1,560 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

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

What is the equivalent of the C++ Pair<L,R> in Java?

In a thread on comp.lang.java.help, Hunter Gratzner ...READ MORE

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

How can we use wait and notify in Java?

You can refer to this: synchronized (someObject) { ...READ MORE

Jul 12, 2018 in Java by sophia
• 1,400 points
453 views
0 votes
1 answer

What is the array initialization syntax when not in a declaration?

Probably you'd have to ask the Java ...READ MORE

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

java.lang.UnsupportedClassVersionError: Bad version number in .class file. How to solve this?

I've learned that error messages like this ...READ MORE

Jul 4, 2018 in Java by Annie
• 240 points
721 views
0 votes
1 answer

What's the difference between SoftReference and WeakReference in Java?

Weak references A weak reference, simply put, is a ...READ MORE

Jun 12, 2018 in Java by Rishabh
• 3,620 points
1,659 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
942 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,309 views
0 votes
1 answer

Convert comma-separated String to ArrayList?

List<String> alist = Arrays.asList(str.split("\\s*,\\s*")); The above code splits ...READ MORE

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

Send HTTP request in Java

import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import java.io.IOException; import ...READ MORE

Aug 3, 2018 in Java by samarth295
• 2,220 points
1,481 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
963 views
0 votes
1 answer

Is there any way to write content of Java InputStream to an OutputStream?

org.apache.commons.io.IOUtils from Apache has a method called copy(InputStream,OutputStream).which does ...READ MORE

Jul 6, 2018 in Java by sharth
• 3,370 points
573 views
0 votes
1 answer

How to resolve the java.net.ConnectException in Java?

If you are getting java.net.ConnectionException, it means ...READ MORE

Jun 4, 2018 in Java by Akrati
• 3,190 points
1,952 views
0 votes
2 answers

How may I programmatically determine operating system in Java?

Use the following program public class Osname {        public ...READ MORE

Jul 6, 2018 in Java by Priyaj
• 58,090 points
523 views
0 votes
1 answer

How to get the name of the currently executing method?

Thread.currentThread().getStackTrace() will usually contain the method you’re ...READ MORE

Jul 5, 2018 in Java by Daisy
• 8,120 points
588 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
943 views
0 votes
1 answer

How to get a platform-dependent new line character in Java?

If you are using Java 1.5 or ...READ MORE

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

how to play sound in java?

 The following code will work fine. But I ...READ MORE

Jun 20, 2018 in Java by scarlett
• 1,290 points
1,207 views
0 votes
1 answer

Is it possible to create a memory leak with Java

Here's a good way to create a memory ...READ MORE

May 31, 2018 in Java by Parth
• 4,630 points
2,086 views
0 votes
1 answer

How to pad an integer with zeros on the left in Java?

Use java.lang.String.format() method. String.format("%05d", number ...READ MORE

May 31, 2018 in Java by Daisy
• 8,120 points
2,058 views
0 votes
2 answers

Avoiding != null statements

public String getPostcode(Person person) { ...READ MORE

Aug 20, 2018 in Java by Daisy
• 8,120 points
444 views
0 votes
1 answer

NoClassDefFoundError in Java

Can’t tell you the exact reason as ...READ MORE

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

How can we remove an element from an array in Java?

You can use ArrayUtils class remove method which ...READ MORE

May 24, 2018 in Java by UshaK
2,337 views
0 votes
1 answer

How to get the Generic type of class at run time?

public class GenericClass<T> { ...READ MORE

Jul 2, 2018 in Java by Akrati
• 3,190 points
626 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
872 views
0 votes
2 answers

How to get input from user using System.console()?

Scanner in = new Scanner(System.in); int i = ...READ MORE

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

Measure time elapsed in Java?

This is also a way to work ...READ MORE

Jul 4, 2018 in Java by scarlett
• 1,290 points
554 views
0 votes
2 answers

What is the difference between = and equals()?

The equals() method compares the "value" inside String instances ...READ MORE

Aug 13, 2018 in Java by Daisy
• 8,120 points
1,076 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,643 views
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,120 points
1,396 views
0 votes
3 answers

How to reverse a string in java?

public static String reverse(String s) { ...READ MORE

Aug 17, 2018 in Java by samarth295
• 2,220 points
1,080 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,120 points
565 views