Most answered questions in Java

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,099 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,929 views
0 votes
3 answers

Increment the date in Java by 1-day

import java.time.LocalDate; public class DateIncrementer { static ...READ MORE

Aug 1, 2018 in Java by Akrati
• 3,190 points
4,224 views
0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

Sep 11, 2018 in Java by Sushmita
• 6,910 points
988 views
0 votes
3 answers

Is it possible to take char input from scanner?

// Use a BufferedReader to read characters ...READ MORE

Sep 7, 2018 in Java by Daisy
• 8,120 points
8,484 views
0 votes
3 answers

Convert date object to a String

We parse the full date to time ...READ MORE

Jul 31, 2018 in Java by samarth295
• 2,220 points
1,220 views
0 votes
3 answers

How can I add new elements to an Array in Java

String[] source = new String[] { "a", ...READ MORE

Sep 19, 2018 in Java by Sushmita
• 6,910 points
11,430 views
0 votes
3 answers

How to parse JSON in Java

import org.json.*; JSONObject obj = new JSONObject(" .... ...READ MORE

Aug 20, 2018 in Java by Daisy
• 8,120 points
3,687 views
0 votes
3 answers

How to check whether a file exists or not in Java?

Using nio we can check whether file ...READ MORE

Aug 14, 2018 in Java by Sushmita
• 6,910 points
3,530 views
0 votes
3 answers

How to read input from Console using Scanner Class?

A simple example: import java.util.Scanner; public class Expl { ...READ MORE

Aug 1, 2018 in Java by samarth295
• 2,220 points
4,511 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,081 views
0 votes
3 answers

How to sort an array in java?

import java.util.Arrays; public class Sort { ...READ MORE

Aug 24, 2018 in Java by Parth
• 4,630 points
859 views
0 votes
3 answers

Check if a String is numeric in Java

Java 8 Lambda Expression is used: String someString ...READ MORE

Sep 3, 2018 in Java by Daisy
• 8,120 points
3,357 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,099 views
0 votes
3 answers

String to Double conversion in java

Double temp = Double.valueOf(str); number = temp.doubleValue(); READ MORE

Sep 10, 2018 in Java by Sushmita
• 6,910 points
1,317 views
+4 votes
3 answers

What are the steps to set Java_home on Windows?

Set Java Home JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [Location ...READ MORE

Sep 18, 2018 in Java by Sushmita
• 6,910 points
1,628 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

Jul 25, 2018 in Java by samarth295
• 2,220 points
3,139 views
0 votes
2 answers

What is the most important feature of java?

The most important feature of Java is ...READ MORE

Nov 29, 2023 in Java by anonymous
• 3,320 points
198 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,144 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
726 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
953 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
474 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
516 views
+1 vote
2 answers

How to find all the classes of a package in Java?

Looking on internet I found this page with ...READ MORE

Nov 16, 2020 in Java by Juan
• 330 points
347,511 views
0 votes
2 answers

I want list of date of every week based on pass dynamically "Mon ,Tue, Wed, Thu, Fri, Sat, Sun" between startDate and endDate using Java 8 LocaleDate

public List<LocalDate> getWeeklyDateByStringofDays(String daysOfWeek, LocalDate startDate, ...READ MORE

Sep 14, 2020 in Java by anonymous
• 190 points
1,085 views
0 votes
2 answers

How do I convert a String to an int in Java?

Use the lines of code mentioned below:- String ...READ MORE

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

Android Studio Gradle project “Unable to start the daemon process /initialization of VM”

In IONIC Go To > Platform > Android >Cordova ...READ MORE

Dec 16, 2020 in Java by Shahzaib
29,367 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,550 views
0 votes
2 answers

How to generate a class at runtime?

Yes, I recently met this library which ...READ MORE

Apr 15, 2020 in Java by Edureka
• 520 points
16,848 views
0 votes
2 answers

How to convert InputStream to byte array in Java?

The class IOUtils, lib: https://mvnrepository.com/artifact/com ...READ MORE

Sep 24, 2020 in Java by Anthony
14,689 views
+1 vote
2 answers

Java: Nested Methods

public class ObjClass {     ObjClass anyMethod() ...READ MORE

Jan 19, 2020 in Java by zemiak
12,426 views
0 votes
2 answers

How do I get distinct element from list in java?

You should use a Set. it doesn't contain duplicates. If ...READ MORE

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

Please explain me the difference between scanner and the buffer reader?

As per your question for reading a ...READ MORE

Aug 27, 2019 in Java by Sirajul
• 59,230 points
3,396 views
+2 votes
2 answers

Can you give me the proper difference between java.util.Date vs java.sql.Date ?

As per Javadoc java.sql.Date is a thin wrapper around millisecond ...READ MORE

Aug 2, 2019 in Java by sampriti
• 1,120 points
14,695 views
0 votes
2 answers

What is the difference between Map and HashMap in java?

The basic difference is : Map is ...READ MORE

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

can i run two tomcat servers on the same linux VM machine?

Hello @Ganesh, To run and configure multiple instances ...READ MORE

Jul 30, 2020 in Java by Niroj
• 82,880 points
5,142 views
0 votes
2 answers

Unable to execute jar- file: “no main manifest attribute”

Check out the answer here https://stackoverflow.com/a/61372736/7747942 READ MORE

Apr 23, 2020 in Java by Anonymous
2,748 views
0 votes
2 answers

What is the meaning of purpose of this command: java -jar <some jar file>.jar ?

JAR (Java Archive) file is a package file ...READ MORE

Mar 22, 2019 in Java by Omkar
• 69,210 points
2,049 views
0 votes
2 answers

String comparission in Java

You should use s1.equals(s2) instead of '==' ...READ MORE

Mar 14, 2019 in Java by anonymous
690 views
0 votes
2 answers

Reverse an Array in Java

If you want to reverse the array ...READ MORE

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

What are the different types of constructor in StringBuilder class?

StringBuilder  we 4  as mentioned below. READ MORE

Sep 1, 2020 in Java by Sri
• 3,190 points
1,054 views
0 votes
2 answers

Converting between java.time.LocalDateTime and java.util.Date

Try this: Date in = new Date(); LocalDateTime ldt ...READ MORE

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

What is coercion in Polymorphism?

Implicit type conversion is called coercion polymorphism. ...READ MORE

Jun 25, 2019 in Java by anonymous
2,644 views
0 votes
2 answers

Why it is not possible to define a static method in a Java interface?

Interfaces are concerned with polymorphism which is ...READ MORE

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

How to ignore exception in Java?

There is no way to basically ignore a ...READ MORE

Aug 16, 2019 in Java by Sirajul
• 59,230 points
11,864 views
0 votes
2 answers

Unfortunately MyApp has stopped. How do I solve this?

The common solution for solving App has ...READ MORE

Mar 6, 2019 in Java by AllisonE
• 180 points
733 views
+1 vote
2 answers

What is an Object?

Hey @preetiagarwal, your description is an answer ...READ MORE

Dec 24, 2018 in Java by Priyaj
• 58,090 points
926 views
+1 vote
2 answers

How to use try & catch block in Java?

Hey @Jino, Using try catch block for your ...READ MORE

Dec 21, 2018 in Java by Nabarupa
1,324 views
0 votes
2 answers

Unable to find valid certification path to requested target

Unfortunately - it could be many things ...READ MORE

Dec 15, 2020 in Java by Roshni
• 10,520 points
41,814 views
0 votes
2 answers

How to iterate in a HashMap in Java?

Iterating using Iterator. Using Generics: Map<Integer, Integer> map = ...READ MORE

Aug 28, 2019 in Java by Sirajul
• 59,230 points
744 views