Trending questions in Java

0 votes
1 answer

does java support operator overloading?

Java doesn't supports operator overloading because it's just a ...READ MORE

Jun 18, 2018 in Java by Akrati
• 960 points
41,227 views
0 votes
2 answers

Reading a plain text file in Java

Read a plain text file: Java Code: import java.io.BufferedReader; import ...READ MORE

Dec 29, 2020 in Java by Nikita
1,209 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,910 points

edited Jul 6, 2023 by Khan Sarfaraz 1,392 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,009 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,910 points

edited Jul 6, 2023 by Khan Sarfaraz 967 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,910 points
956 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,910 points
1,246 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,520 points
844 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
765 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,910 points
998 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,880 points
2,388 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,910 points
954 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,910 points
996 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,910 points
605 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,440 points
495 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
535 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,910 points
467 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
497 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,910 points
833 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,910 points

edited Jul 4, 2023 by Khan Sarfaraz 426 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,910 points
726 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,910 points

edited Jul 5, 2023 by Khan Sarfaraz 718 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,230 points

edited Jun 22, 2023 by Khan Sarfaraz 407 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,910 points
350 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,910 points
869 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,910 points
579 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,910 points
515 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,910 points
385 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,910 points
414 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,910 points
396 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,910 points
289 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,910 points
2,110 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,880 points
9,161 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,540 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,880 points
6,075 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 1,765 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
711 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,880 points
8,712 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,120 points
30,396 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,261 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,880 points
316 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
591 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,910 points
1,480 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,630 points
34,319 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,880 points
7,975 views
+1 vote
10 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
34,325 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,520 points

edited Jul 4, 2023 by Khan Sarfaraz 3,679 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,440 points
6,048 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,880 points
7,415 views
0 votes
2 answers

How to log SQL statements in Spring Boot?

HI.. try using this in your properties file: logging.level.org. ...READ MORE

Sep 25, 2020 in Java by SRI

edited Sep 25, 2020 by Sirajul 4,578 views