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,920 points
1,902 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
2,731 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
5,035 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,920 points
2,014 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,140 points
9,804 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
2,125 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,920 points
14,460 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,140 points
4,517 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,920 points
4,801 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
6,060 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
2,167 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,640 points
1,697 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,140 points
4,227 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
3,076 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,920 points
2,222 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,920 points
2,989 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
4,118 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,360 points
856 views
0 votes
2 answers

I recently used Crockford's JSLint to check some of my JavaScript code, and it returned the following error:

"Use strict"; is a directive in JavaScript ...READ MORE

Sep 18, 2023 in Java by Rahul
• 240 points
1,085 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
2,125 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,338 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,676 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
1,103 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
1,064 views
+3 votes
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
• 350 points
349,115 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,822 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,730 points
3,783 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
31,629 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 5,278 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
19,966 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
16,481 views
+1 vote
2 answers

Java: Nested Methods

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

Jan 19, 2020 in Java by zemiak
14,841 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,190 points
2,504 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,190 points
4,128 views
+2 votes
2 answers

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

 java.sql.Date is a thin wrapper around millisecond value ...READ MORE

Aug 2, 2019 in Java by sampriti
• 1,120 points
16,224 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,190 points
29,953 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,800 points
6,238 views
0 votes
2 answers

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

Check out the answer here. READ MORE

Apr 23, 2020 in Java by Anonymous
3,765 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,180 points
3,158 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
1,356 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,190 points
1,177 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,849 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,190 points
3,331 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
3,465 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,190 points
2,569 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,190 points
13,623 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
1,539 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,020 points
1,898 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
2,529 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,440 points
42,885 views