Trending questions in Java

0 votes
1 answer

How to convert Java String into byte[]?

The object your method decompressGZIP() needs is a byte[]. So the ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points
1,593 views
0 votes
1 answer

How to round a number to n decimal places in Java?

Use setRoundingMode, set the RoundingMode explicitly to handle your issue ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points

edited Jul 6, 2023 by Khan Sarfaraz 1,838 views
0 votes
1 answer

When to use LinkedList over ArrayList in Java?

LinkedList and ArrayList are two different implementations of the List ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points
1,855 views
0 votes
4 answers

How to convert a char to a String?

There are two ways you can do ...READ MORE

Dec 29, 2020 in Java by Roshni
• 10,480 points
1,271 views
0 votes
2 answers

Java string to date conversion

We can convert String to Date in java using parse() method ...READ MORE

Dec 29, 2020 in Java by Nikita
1,346 views
0 votes
1 answer

How to get the current date/time in Java?

It depends on what form of date/time ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points
1,294 views
0 votes
1 answer

How to append text to an existing file in Java?

Java 7+ If you just need to do ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points

edited Jul 6, 2023 by Khan Sarfaraz 1,236 views
0 votes
1 answer

Sort ArrayList of custom Objects by property

Since Date implements Comparable, it has a compareTo method just like String does. So your ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
1,509 views
0 votes
2 answers

When to use static methods

Java main() method is always static, so that compiler ...READ MORE

Dec 29, 2020 in Java by Reshma
1,024 views
0 votes
1 answer

Convert ArrayList<String> to String[] array

Use like this. List<String> stockList = new ArrayList<String>(); stockList.add("stock1"); stockList.add("stock2"); String[] ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
1,321 views
0 votes
1 answer

What does “Could not find or load main class” mean?

First of all, you need to understand ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
1,281 views
0 votes
1 answer

How do I determine whether an array contains a particular value in Java?

Arrays.asList(yourArray).contains(yourValue) Warning: this doesn't work for arrays of ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points
1,299 views
0 votes
1 answer

How to return JSON response from Flask view?

Hello, Pass the summary data to the jsonify function, which ...READ MORE

Nov 20, 2020 in Java by Niroj
• 82,840 points
2,619 views
0 votes
1 answer

How to install the JDK on Ubuntu Linux?

Open Terminal from Application Dash or press Ctrl+Alt+T Update repository: sudo add-apt-repository ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points
787 views
0 votes
2 answers

How to make a new List in Java?

Initializing a List in Java The Java.util.List is a child ...READ MORE

Dec 28, 2020 in Java by Thomas Walenta
819 views
0 votes
2 answers

File to byte[] in Java?

Example 1: Convert File to byte[] import java.io.IOException; import ...READ MORE

Dec 28, 2020 in Java by Reshma
773 views
0 votes
1 answer

How do I convert from int to String?

Normal ways would be Integer.toString(i) or String.valueOf(i). The concatenation will work, ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points
716 views
0 votes
1 answer

How to remove the last character from a string?

Hi@akhtar, You can use the StringBuffer class. It provides ...READ MORE

Dec 30, 2020 in Java by MD
• 95,460 points
683 views
0 votes
1 answer

What are the differences between a HashMap and a Hashtable in Java?

There are several differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points
1,064 views
0 votes
1 answer

Static Classes In Java

Java has static nested classes but it sounds like ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,770 points

edited Jul 5, 2023 by Khan Sarfaraz 941 views
0 votes
1 answer

How do I copy an object in Java?

Create a copy constructor: class DummyBean { ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points

edited Jul 4, 2023 by Khan Sarfaraz 633 views
0 votes
1 answer

How to convert a Set to List in Java?

Hi@MD, The most straightforward way to convert a ...READ MORE

Dec 30, 2020 in Java by akhtar
• 38,260 points

edited Jun 22, 2023 by Khan Sarfaraz 627 views
0 votes
1 answer

Converting array to list in Java

In your example, it is because you ...READ MORE

Dec 23, 2020 in Java by Gitika
• 65,770 points
911 views
0 votes
1 answer

How do I join two lists in Java?

In Java 8: List<String> newList = Stream.concat(listOne.stream(), listTwo.stream()) ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,770 points
543 views
0 votes
1 answer

Is it possible to upload a file from desktop to web using Selenide?

Hi, @Nikhil, Yes it's possible to drop a ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,770 points
1,087 views
0 votes
1 answer

How do I generate random integers within a specific range in Java?

Before Java 1.7, the standard way to ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
824 views
0 votes
1 answer

How can I solve this: To prevent a memory leak, the JDBC Driver has been forcibly unregistered

What can you do? Ignore these warnings. Tomcat ...READ MORE

Jan 8, 2019 in Java by Daisy
• 8,140 points
31,656 views
0 votes
1 answer

Iterate through a HashMap.

Iterate through the entrySet() like so: public static void printMap(Map ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
778 views
+1 vote
1 answer

Multithreading in Java with priorities

HI, @Juan, By default, a thread inherits the priority of its parent thread. ...READ MORE

Nov 6, 2020 in Java by Gitika
• 65,770 points
2,596 views
0 votes
1 answer

How does the Java 'for each' loop work?

for (Iterator<String> i = someIterable.iterator(); i.hasNext();) { ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,770 points
596 views
0 votes
1 answer

How to create create an ArrayList from array?

new ArrayList<>(Arrays.asList(array)); READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points
633 views
0 votes
1 answer

Avoiding NullPointerException in Java

This to me sounds like a reasonably ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points

edited Nov 13 by Khan Sarfaraz 625 views
0 votes
1 answer

IllegalArgumentException: navigation destination xxx is unknown to this NavController

Hello @kartik, Check currentDestination before calling navigate might be helpful. For ...READ MORE

May 26, 2020 in Java by Niroj
• 82,840 points
9,648 views
0 votes
1 answer

How to get a context in a recycler view adapter?

Hii, You can add global variable: private Context context; then ...READ MORE

May 26, 2020 in Java by Niroj
• 82,840 points
9,527 views
0 votes
1 answer

Error:serializable class Foo does not declare a static final serialVersionUID field of type long

Hello @kartik, If you're serializing just because you ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,840 points
6,795 views
0 votes
1 answer

Why is subtracting these two times (in 1927) giving a strange result?

In TZDB 2014f, the time of the ...READ MORE

Dec 21, 2020 in Java by Gitika
• 65,770 points
475 views
0 votes
0 answers

How to store and fetch nested json data from dynamodb in java

I want to maintain a book library. ...READ MORE

Sep 7, 2020 in Java by saswat
• 120 points

edited Sep 7, 2020 by Gitika 4,961 views
0 votes
0 answers

what is cannot find symbol this(SimpleTimeLimiter.create(THREAD_POOL));

Hi, Through command line, I'm trying to compile ...READ MORE

Nov 6, 2020 in Java by zaraaq
• 270 points

edited Nov 6, 2020 by Gitika 2,108 views
0 votes
1 answer

Can i know where is java logs on centos 7?

Hey! Have you checked <user.home>/.java/deployment/log ? READ MORE

Oct 20, 2020 in Java by Kiya
2,716 views
0 votes
0 answers

I have Added all External JAR files but driver not found exception occured

Exception in thread "main" java.lang.Error: Unresolved compilation ...READ MORE

Nov 29, 2020 in Java by Boopathy
• 370 points
942 views
+1 vote
9 answers

How to make mock to void methods with mockito

You can use partial mocking to serve ...READ MORE

Dec 7, 2018 in Java by nitesh
35,295 views
0 votes
1 answer

What does Animal a = (Animal) data[0]; do?

Hello @zaraaq , You can refer this for your ...READ MORE

Dec 2, 2020 in Java by Niroj
• 82,840 points
514 views
0 votes
1 answer

How to set path if java is installed in E drive or D drive rather than c

Hello, @Amazing, It doesn't really matter where you ...READ MORE

Sep 1, 2020 in Java by Roshni
• 10,480 points

edited Jul 4, 2023 by Khan Sarfaraz 4,471 views
0 votes
1 answer

Could not include JAR files

Hey, @Boopathy, Which command do you use to ...READ MORE

Oct 27, 2020 in Java by Gitika
• 65,770 points
1,927 views
0 votes
0 answers

Apache maven vs Eclipse maven plugin

Hi, I want to install maven but don't ...READ MORE

Nov 25, 2020 in Java by zaraaq
• 270 points
725 views
0 votes
1 answer

object references an unsaved transient instance - save the transient instance before flushing

You should add cascade="all" (if using xml) ...READ MORE

Sep 26, 2018 in Java by Parth
• 4,640 points
34,805 views
0 votes
1 answer

How to launch Google Maps Directions via an intent on Android?

Hello @kartik, If you are interested in showing the ...READ MORE

May 25, 2020 in Java by Niroj
• 82,840 points
8,363 views
0 votes
1 answer

How to Install Java in Windows system?

Hi@akhtar, You can follow the below-given steps to install ...READ MORE

Jul 7, 2020 in Java by MD
• 95,460 points
6,489 views
0 votes
1 answer

How to determine programmatically the current active profile using Spring boot ?

Hello, It doesn't matter is your app Boot ...READ MORE

May 21, 2020 in Java by Niroj
• 82,840 points

edited Mar 4, 2022 by Sarfaraz 8,301 views
0 votes
1 answer

How to parse JSON Array in Android?

Hello @kartik, use the following snippet to parse ...READ MORE

May 26, 2020 in Java by Niroj
• 82,840 points
7,938 views