Most answered questions in Java

+1 vote
2 answers

Factorial of a number using while loop

import java.util.*; public class Fact { ...READ MORE

Mar 19, 2020 in Java by leela
• 140 points
3,887 views
0 votes
2 answers

In Java, what is the best way to determine the size of an object?

I happened to find a java class "jdk.nashorn.internal.ir.debug.ObjectSizeCalculator", ...READ MORE

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

How to move or copy a file in Java

The new JAVA Specification Request 203 -NIO will ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 59,230 points
685 views
0 votes
2 answers

Maximum size of an Java array

There are actually two limits.  The maximum element ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 59,230 points
5,430 views
0 votes
2 answers

How to convert List<Integer> to int[] in Java?

In addition to Commons Lang, you can ...READ MORE

Aug 20, 2019 in Java by Sirajul
• 59,230 points
14,790 views
0 votes
2 answers

Splitting a string between letters and digits

Using Python: https://stackoverflow.com/a/63936955/8117673 READ MORE

Sep 17, 2020 in Java by Himanshu
4,108 views
0 votes
2 answers

Java: convert List<String> to a String

With a java 8 collector, this can ...READ MORE

Aug 30, 2019 in Java by Sirajul
• 59,230 points
544 views
0 votes
2 answers

What's the difference between @JoinColumn and mappedBy when using a JPA @OneToMany association?

JPA mapping annotation can be classified as ...READ MORE

Oct 28, 2020 in Java by bjjj
• 140 points
20,257 views
0 votes
2 answers

What are all the different ways to create an object in Java?

There are different ways you could do this ...READ MORE

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

How to parse/format dates with LocalDateTime? (Java 8)

Converting LocalDateTime to Time Zone ISO8601 String LocalDateTime ...READ MORE

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

Reading an InputStream & coverting it into a String in Java?

Apache Commons allows: String myString = IOUtils.toString(myInputStream, "UTF-8"); And ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
827 views
0 votes
2 answers

Why are you not able to declare a class as static in Java?

A static keyword  can be used with ...READ MORE

Jun 11, 2019 in Java by Neha
• 330 points
1,107 views
0 votes
2 answers

How to parse a date?

SimpleDateFormat parser=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz ...READ MORE

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

Does Java thread.sleep() puts swing ui to sleep?

You are correct about the code putting ...READ MORE

Oct 24, 2018 in Java by Sushmita
• 6,910 points
4,587 views
0 votes
2 answers

How can I address the unchecked cast warnings?

@SuppressWarnings("unchecked") READ MORE

Mar 21, 2019 in Java by anonymous
24,392 views
0 votes
2 answers

How to check if a string has only letters

You could probably use Java 8 lambda ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
2,752 views
0 votes
2 answers

How do we convert only the second letter of every word in a string to uppercase ?

The following code will perform your desired ...READ MORE

Aug 29, 2018 in Java by curious
• 560 points
11,224 views
0 votes
2 answers

Java Security: Illegal key size or default parameters

Starting from Java 9 or 8u151, you ...READ MORE

Aug 23, 2018 in Java by Parth
• 4,630 points
8,178 views
0 votes
2 answers

How to convert a byte into Hexadecimal in Java?

private static final String ...READ MORE

Aug 29, 2019 in Java by Sirajul
• 59,230 points
1,741 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look to this example: https://github.com/burningwave/co ...READ MORE

Dec 21, 2019 in Java by Roberto
• 460 points

edited Jul 7, 2020 by Roberto 36,449 views
0 votes
2 answers

What is null in java?

"null" is a reference type and its ...READ MORE

Jul 31, 2018 in Java by Mrunal
• 680 points
643 views
0 votes
2 answers

What is immutable string in java?

To answer your question, the String is ...READ MORE

Feb 9, 2022 in Java by Soham
• 9,700 points
593 views
0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

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

How do we convert JSON to Map in Java

When you don't know structure of json. ...READ MORE

Oct 31, 2018 in Java by Sushmita
• 6,910 points
5,409 views
0 votes
2 answers

How to return multiple objects from a Java method?

In the event the method you're calling ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
8,199 views
0 votes
2 answers

Is there any way to declare an array in-line?

Another way to do that, if you ...READ MORE

Aug 30, 2019 in Java by Sirajul
• 59,230 points
389 views
0 votes
2 answers

How to play .mp3 and .wav in Java?

We can use Java API to play ...READ MORE

Dec 7, 2018 in Java by Sushmita
• 6,910 points
5,330 views
0 votes
2 answers

What is the difference between Type List and type ArrayList in Java

By List, you actually tell, that your object ...READ MORE

Aug 28, 2019 in Java by Sirajul
• 59,230 points
2,246 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
524 views
0 votes
2 answers

Give an example for encryption and decryption in AES using Java

getfullstring: Splashscreen.text >>> READ MORE

May 8, 2019 in Java by anonymous
6,555 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
940 views
0 votes
2 answers

How to left pad a string with zero in java?

String paddedString = org.apache.commons.lang.StringUtils.leftPad("129018", 10, "0") the second ...READ MORE

Aug 31, 2018 in Java by Sushmita
• 6,910 points
2,836 views
0 votes
2 answers

Is there a SortedList in Java?

Since all lists are already "sorted" by ...READ MORE

Nov 2, 2018 in Java by Sushmita
• 6,910 points
4,137 views
0 votes
2 answers

How do I get the size of a java.sql.ResultSet?

You could probably do rows-count. ResultSet rs = ...READ MORE

Aug 22, 2019 in Java by Sirajul
• 59,230 points
12,336 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

What is the difference between getAttribute() and getParameter() in java?

getParameter() returns http request parameters. Those passed from ...READ MORE

Aug 28, 2019 in Java by Sirajul
• 59,230 points
21,396 views
0 votes
2 answers

How can we convert java.util.Date to java.sql.date in Java?

It's easy to convert a java.util.Date object ...READ MORE

Aug 27, 2019 in Java by Sirajul
• 59,230 points
1,030 views
0 votes
2 answers

How does random shuffling of an array

Here is a simple way using an ArrayList: List<Integer> ...READ MORE

Nov 2, 2018 in Java by Sushmita
• 6,910 points
641 views
+2 votes
2 answers

How to connect to Oracle using Service Name instead of SID?

HII.. I hope this information may help you- Thin-style ...READ MORE

Sep 29, 2020 in Java by SRI
9,576 views
0 votes
2 answers

How can we pass a function as a parameter in java?

Java 8 and above Using Java 8+ lambda ...READ MORE

Aug 28, 2018 in Java by Daisy
• 8,120 points
1,193 views
0 votes
2 answers

How do I rename a file using Java

// File (or directory) with old name File ...READ MORE

Oct 5, 2018 in Java by Sushmita
• 6,910 points
561 views
0 votes
2 answers

Setting Proxy for JVM usage

JVM uses the proxy to make HTTP ...READ MORE

Aug 26, 2019 in Java by Sirajul
• 59,230 points
2,273 views
0 votes
2 answers

How can I do url string decoding in java

We can use URLDecoder: URLDecoder.decode( url, "UTF-8" ); READ MORE

Dec 7, 2018 in Java by Sushmita
• 6,910 points
555 views
+1 vote
2 answers

Is there a code to find 64-bit JVM or 32-bit JVM (from within a program)?

Do I need to understand the difference ...READ MORE

Jun 11, 2019 in Java by Jim
• 810 points
2,017 views
0 votes
2 answers

How to convert a java string into byte array

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

Aug 22, 2019 in Java by Sirajul
• 59,230 points
1,151 views
+1 vote
2 answers

Calculating date/time difference in Java

We can also use java.util.concurrent.TimeUnit class. long diff = d2.getTime() ...READ MORE

Aug 28, 2018 in Java by Sushmita
• 6,910 points
23,246 views
0 votes
2 answers

Resolving PKIX path building failed Error?

You need to add the certificate for App2 to ...READ MORE

Sep 24, 2018 in Java by Sushmita
• 6,910 points
42,384 views
0 votes
2 answers

Escape Characters in Java

These are escape characters which are used ...READ MORE

Oct 15, 2018 in Java by Daisy
• 8,120 points
719 views
0 votes
2 answers

How can we assert, that a certain Exception is thrown in JUnit 4 tests?

@Test(expected = IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { ...READ MORE

Dec 10, 2018 in Java by Sushmita
• 6,910 points
1,196 views
0 votes
2 answers

What is the use of final class in java?

In Java, items with the final modifier cannot be ...READ MORE

Oct 5, 2018 in Java by Daisy
• 8,120 points
1,577 views