Trending questions in Java

0 votes
1 answer

Calling SOAP web services on Android using JAVA

Android does not provide any sort of ...READ MORE

Jun 28, 2018 in Java by Sushmita
• 6,920 points
2,674 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,270 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,578 views
0 votes
2 answers

How can I sort values of a Map in Java using its key

Assuming TreeMap is not good for you ...READ MORE

Oct 10, 2018 in Java by Sushmita
• 6,920 points
1,205 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

Aug 29, 2018 in Java by Daisy
• 8,140 points
1,764 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

May 7, 2018 in Java by code.reaper12
• 3,500 points
4,703 views
0 votes
2 answers

How do I use a Priority Queue

Use the constructor overload which takes a Comparator<? ...READ MORE

Oct 10, 2018 in Java by Sushmita
• 6,920 points
1,021 views
+1 vote
1 answer

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

This error means you're trying to load ...READ MORE

Jun 8, 2018 in Java by Rishabh
• 3,620 points
3,220 views
0 votes
2 answers

How can I get the filenames of all files in a folder which may or may not contain duplicates

List<String> results = new ArrayList<String>(); File[] files = ...READ MORE

Sep 12, 2018 in Java by Sushmita
• 6,920 points
1,910 views
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

May 29, 2018 in Java by geek.erkami
• 2,680 points
3,651 views
0 votes
2 answers

Can the size of dynamic array be changed?

import java.util.List; import java.util.ArrayList; import java.util.Random; public class A ...READ MORE

Aug 31, 2018 in Java by Sushmita
• 6,920 points
1,279 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,269 views
0 votes
1 answer

How to pretty print XML from Java?

Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //initialize StreamResult ...READ MORE

Jul 4, 2018 in Java by Akrati
• 3,190 points
1,936 views
0 votes
1 answer

How can I calculate number of days between two dates?

You may refer this. This might work ...READ MORE

Jul 19, 2018 in Java by Akrati
• 3,190 points
1,235 views
0 votes
2 answers

Performing Iteration over each entry in a 'Map'

In Java 8 you can do it ...READ MORE

Oct 24, 2018 in Java by Sushmita
• 6,920 points
1,104 views
0 votes
1 answer

Multiple return statements in Java

Yes, you have guessed it right. Language ...READ MORE

Jun 28, 2018 in Java by geek.erkami
• 2,680 points
2,161 views
0 votes
1 answer

What is Classpath in java?

Classpath is a parameter in the Java virtual machine or ...READ MORE

Jun 5, 2018 in Java by Daisy
• 8,140 points
3,121 views
+1 vote
1 answer

concat() vs “+” operator : In Java for String concatenation

Basically, there are two important differences between ...READ MORE

Apr 27, 2018 in Java by Rishabh
• 3,620 points
4,748 views
0 votes
1 answer

While using next() or nextfoo() , the upcoming nextLine() is skipped by scanner

That's because the Scanner.nextInt method does not ...READ MORE

Jun 6, 2018 in Java by mitto
• 160 points
3,062 views
0 votes
2 answers

How a static map can be initialized?

public class Test { ...READ MORE

Sep 12, 2018 in Java by Sushmita
• 6,920 points
1,080 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
940 views
+1 vote
3 answers

Copy Java Array and make a duplicate of it

int[] a = {1,2,3,4,5}; int[] b = Arrays.copyOf(a, ...READ MORE

Aug 30, 2018 in Java by Sushmita
• 6,920 points
1,698 views
0 votes
1 answer

How to use wait() and notify() concept in producer consumer situation

In this program, we have two threads ...READ MORE

Jul 20, 2018 in Java by Kalgi
• 52,350 points
1,122 views
0 votes
1 answer

How can we import javax.servlet API in Eclipse?

Before installing Eclipse, ensure that you are ...READ MORE

Jun 7, 2018 in Java by Parth
• 4,640 points
2,990 views
0 votes
2 answers

Can we catch multiple exceptions in the same catch clause in Java?

In Java 6 and before versions, we ...READ MORE

Aug 10, 2018 in Java by sharth
• 3,370 points
1,404 views
0 votes
1 answer

Get parameters from the URL with JSP

To delete the subject record with its ...READ MORE

May 29, 2018 in Java by Parth
• 4,640 points
3,386 views
0 votes
1 answer

Examples of GoF Design Patterns in Java's core libraries

Observer pattern throughout whole swing (Observable, Observer) MVC also ...READ MORE

Jun 27, 2018 in Java by developer_1
• 3,350 points
2,052 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

Jul 26, 2018 in Java by samarth295
• 2,220 points
2,923 views
0 votes
2 answers

How to concatenate two arrays in Java?

public <T> T[] concatenate(T[] a, T[] b) ...READ MORE

Jul 19, 2018 in Java by Sushmita
• 6,920 points
2,863 views
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,413 views
0 votes
1 answer

Behavior of Integer Wrapper class and == operator

Well, this is happening because of the ...READ MORE

Jun 7, 2018 in Java by v.liyyah
• 1,300 points
2,820 views
0 votes
1 answer

Why there is the need of getters and setters in java

In Java getters and setters are completely ...READ MORE

Jun 26, 2018 in Java by scarlett
• 1,290 points
1,964 views
0 votes
2 answers

How to break the nested loop in Java?

You can use break with a label for the ...READ MORE

Sep 20, 2018 in Java by Sushmita
• 6,920 points
1,237 views
0 votes
1 answer

Convert Milliseconds to “X mins, x seconds” in Java?

I wrote a function which converts milliseconds ...READ MORE

May 30, 2018 in Java by Rishabh
• 3,620 points
3,108 views
0 votes
1 answer

How can we run the .jar file by double clicking on windows 7 (64)?

Use the following method to run the ...READ MORE

Jun 28, 2018 in Java by sharth
• 3,370 points
1,852 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
1,431 views
0 votes
1 answer

What is the difference between static and inner class?

An inner class, cannot be static, so ...READ MORE

Jul 11, 2018 in Java by sophia
• 1,400 points
1,226 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
1,727 views
0 votes
2 answers

Does the finally block always execute in Java?

public static void main(String[] args) { ...READ MORE

Aug 8, 2018 in Java by Sushmita
• 6,920 points
2,057 views
0 votes
2 answers

Does Java allow to create static classes?

Java has "static nested classes", but they ...READ MORE

Sep 5, 2018 in Java by Sushmita
• 6,920 points
1,147 views
0 votes
1 answer

Difference between JSF, Servlet and JSP?

Servlet - it's java server side layer. JSP ...READ MORE

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

Running Command Line in Java

You may refer this: Runtime rt = Runtime.getRuntime(); Process ...READ MORE

Jul 20, 2018 in Java by Akrati
• 960 points
754 views
0 votes
2 answers

How to round up a value to 2 decimal places?

double d = 2.34568; DecimalFormat f = new ...READ MORE

Aug 30, 2018 in Java by Sushmita
• 6,920 points
1,362 views
0 votes
1 answer

How can we split a comma separated String in Java?

String str = "..."; // write the ...READ MORE

Jun 12, 2018 in Java by Parth
• 4,640 points
2,376 views
0 votes
1 answer

What is the use of serialVersionUID ?

The docs for java.io.Serializable are probably about as good ...READ MORE

Jun 21, 2018 in Java by Rishabh
• 3,620 points
1,961 views
0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

Sep 5, 2018 in Java by Sushmita
• 6,920 points
1,381 views
0 votes
2 answers

How does '&&' (AND) and '||' (OR) statements work inside an IF condition ?

Short circuit here means that the second ...READ MORE

Sep 19, 2018 in Java by Sushmita
• 6,920 points
1,022 views
0 votes
1 answer

Check whether the string is palindrome or not?

You may refer the below code: public static ...READ MORE

Jul 11, 2018 in Java by Akrati
• 3,190 points
1,076 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,489 views
–1 vote
1 answer

What is the difference between oracle JDK and open JDK

Both OpenJDK and Oracle JDK are created ...READ MORE

Jul 10, 2018 in Java by Akrati
• 3,190 points
1,103 views