Trending questions in Java

0 votes
2 answers

Ho do I Iterate through a HashMap which contains duplicate values

for (Map.Entry<String, String> item : params.entrySet()) { ...READ MORE

Jul 24, 2018 in Java by samarth295
• 2,220 points
4,789 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 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,510 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

Dec 10, 2018 in Java by Sushmita
• 6,910 points
770 views
0 votes
1 answer

Removing an Integer from a List<Integer> in Java

In Java, the method best suiting your argument ...READ MORE

Aug 24, 2018 in Java by anonymous
1,291 views
0 votes
1 answer

DEX decompilation in Java Sourcecode

down voteaccep It's easy Get these tools: 1) dex2jar to translate dex ...READ MORE

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

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

Aug 23, 2018 in Java by Daisy
• 8,120 points
3,758 views
0 votes
1 answer

Add jars to maven 2 build class path without installing them?

wn voteA quick&dirty batch solution (based on Alex's answer): libs.bat @ECHO ...READ MORE

Aug 30, 2018 in Java by samarth295
• 2,220 points
937 views
0 votes
2 answers

Java enum lookup using a String

Check this...Java Enum in details READ MORE

Dec 4, 2018 in Java by allenvarna
• 540 points
702 views
0 votes
1 answer

Generate UML diagrams from Java code?

You could also give the netbeans UML ...READ MORE

Aug 30, 2018 in Java by samarth295
• 2,220 points
832 views
0 votes
2 answers

What is the use of final class in java?

In Java, items with the final modifier cannot be ...READ MORE

Oct 5, 2018 in Java by Daisy
• 8,120 points
1,576 views
0 votes
2 answers

How does random shuffling of an array

Here is a simple way using an ArrayList: List<Integer> ...READ MORE

Nov 2, 2018 in Java by Sushmita
• 6,910 points
640 views
0 votes
2 answers

When to use LinkedList and ArrayList in Java?

ArrayList is what you want. LinkedList is almost always a ...READ MORE

Dec 11, 2018 in Java by Sushmita
• 6,910 points
848 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

What is ^ operator in java?

It's bitwise XOR, Java does not have ...READ MORE

Oct 31, 2018 in Java by Sushmita
• 6,910 points
723 views
0 votes
1 answer

How to calculate the interval between 2 dates

The following code might be helpful: public static ...READ MORE

Aug 29, 2018 in Java by bug_seeker
• 15,520 points
667 views
0 votes
1 answer

How to read an XML file using XPath in Java?

Import the packages required to work with ...READ MORE

Jun 14, 2018 in Java by Akrati
• 3,190 points
3,942 views
0 votes
1 answer

Gracefully stopping a java thread

The preferable way will be to use a ...READ MORE

Aug 21, 2018 in Java by anto.trigg4
• 3,440 points
1,011 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
1 answer

Retrieve a file from a server via SFTP

Below is an example using Apache Common ...READ MORE

Aug 28, 2018 in Java by samarth295
• 2,220 points
670 views
0 votes
2 answers

How to sort an ArrayList of custom object by property in Java?

You can Sort using java 8 yourList.sort(Comparator.comparing(Classname::getName)); or  yourList.stream().forEach(a -> ...READ MORE

Aug 14, 2018 in Java by samarth295
• 2,220 points
2,715 views
0 votes
2 answers

One line initialization of an ArrayList object in Java

In Java 8 or earlier: List<String> string = ...READ MORE

Jul 26, 2018 in Java by samarth295
• 2,220 points
4,134 views
0 votes
1 answer

Enums be subclassed to add new elements?

I suggest you take the other way ...READ MORE

Aug 29, 2018 in Java by Parth
• 4,630 points
454 views
0 votes
1 answer

How can we set environment variables from java?

For setting the environment variable, you can ...READ MORE

Jun 21, 2018 in Java by Akrati
• 960 points
3,408 views
+1 vote
1 answer

How do I do a HTTP GET?

If you don't want to use external ...READ MORE

Aug 28, 2018 in Java by Neha
• 6,300 points
428 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,529 views
0 votes
1 answer

get a class instance of generics type T

The short answer is, that there is ...READ MORE

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

java.lang.OutOfMemoryError: GC overhead limit exceeded Error

This simply means that for some reason ...READ MORE

May 31, 2018 in Java by misc.edu04
• 1,450 points
4,263 views
0 votes
2 answers

What's the best way to check if a String represents an integer in Java?

You can also use regular expression. str.matches("-?\\d+"); It will ...READ MORE

Aug 9, 2018 in Java by Daisy
• 8,120 points
3,425 views
0 votes
1 answer

Maximum depth of the java call stack

Well, there is no definite depth. It ...READ MORE

Jul 24, 2018 in Java by code.reaper12
• 3,500 points
1,896 views
0 votes
3 answers

Is there any goto statement in java?

So they could be used one day ...READ MORE

Oct 15, 2018 in Java by Daisy
• 8,120 points
888 views
0 votes
1 answer

Replace String with another in java

String s = "HelloSuresh"; s = s.replace("Hello",""); System.out.pri ...READ MORE

Aug 21, 2018 in Java by Parth
• 4,630 points
601 views
0 votes
2 answers

Escape Characters in Java

These are escape characters which are used ...READ MORE

Oct 15, 2018 in Java by Daisy
• 8,120 points
719 views
0 votes
1 answer

@Autowired annotation in Spring Framework

The @Autowired annotation provides more accurate control over where ...READ MORE

Aug 3, 2018 in Java by geek.erkami
• 2,680 points
1,396 views
0 votes
1 answer

How to replace 2 or more spaces with a single space in String and how to delete leading and trailing spaces?

before=" Hello world "; String after ...READ MORE

Aug 22, 2018 in Java by Parth
• 4,630 points
532 views
0 votes
1 answer

Iterable.forEach() vs foreach loop

The advantage comes into account when the ...READ MORE

Aug 21, 2018 in Java by Parth
• 4,630 points
559 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

Jul 26, 2018 in Java by Mrunal
• 680 points
1,664 views
0 votes
1 answer

Double decimal formatting in Java

Using String.format, you can do this: double price ...READ MORE

Aug 23, 2018 in Java by Parth
• 4,630 points
388 views
0 votes
4 answers

Remove extra spaces from string in java

import java.util.regex.Matcher; import java.util.regex.Pattern; String pattern="[\\s]"; String replace=""; part="name=john age=13 year=2001"; Pattern ...READ MORE

Sep 10, 2018 in Java by Parth
• 4,630 points
2,648 views
0 votes
1 answer

How to add row in JTable

To create a table: JTable table = new ...READ MORE

Jun 29, 2018 in Java by Akrati
• 960 points
2,666 views
0 votes
2 answers

How do I rename a file using Java

// File (or directory) with old name File ...READ MORE

Oct 5, 2018 in Java by Sushmita
• 6,910 points
559 views
0 votes
1 answer

How to retrieve column names from java.sql.ResultSet?

You may refer the below code: ResultSet ...READ MORE

Jul 4, 2018 in Java by sophia
• 1,400 points
2,428 views
0 votes
1 answer

Checking results values using Java ResultSet

As per my knowledge what you are ...READ MORE

Aug 16, 2018 in Java by code.reaper12
• 3,500 points
469 views
0 votes
1 answer

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

In your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > ...READ MORE

Jun 18, 2018 in Java by Parth
• 4,630 points
3,004 views
0 votes
2 answers

How can we pass a function as a parameter in java?

Java 8 and above Using Java 8+ lambda ...READ MORE

Aug 28, 2018 in Java by Daisy
• 8,120 points
1,193 views
0 votes
1 answer

How to encrypt string in Java

String s1="sharth"; char[] s2=s1.toCharArray(); int s3= s2.length; ...READ MORE

Jul 24, 2018 in Java by scarlett
• 1,290 points
1,428 views
0 votes
1 answer

How can we remove html tags from a string?

You can use HTML parser. This is ...READ MORE

Jun 4, 2018 in Java by sophia
• 1,400 points
3,543 views
0 votes
2 answers

Counting no of Occurrence of a particular character inside a string in Java

We can find out the no. of ...READ MORE

Sep 7, 2018 in Java by Sushmita
• 6,910 points
2,275 views
0 votes
1 answer

A Java collection of value pairs? (tuples?)

The Pair class is one of those ...READ MORE

Jul 2, 2018 in Java by sharth
• 3,370 points
2,191 views
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,910 points
2,314 views