Most viewed questions in Java

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
767 views
0 votes
1 answer

Default Object.toString() in hashcode

Well, the hash code object is the ...READ MORE

Oct 31, 2018 in Java by code.reaper12
• 3,500 points
766 views
0 votes
2 answers

How to convert ArrayList<String> to String[] in Java

Try this:  String[] strArray = arrayList.toArray(new Str ...READ MORE

Aug 21, 2019 in Java by Sirajul
• 59,230 points
763 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
762 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

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

What is abstract class in java?

A class that is declared with abstract ...READ MORE

Jun 11, 2018 in Java by Daisy
• 8,120 points
759 views
0 votes
0 answers

java.net.SocketException: Connection reset

I was having an error when I ...READ MORE

May 8, 2022 in Java by Kichu
• 19,050 points
755 views
0 votes
1 answer

How can we get the current location in Android?

First you need to define a LocationListener to handle ...READ MORE

Sep 25, 2018 in Java by Parth
• 4,630 points
754 views
0 votes
1 answer

Overloaded method for null in Java

The method invoked here will be the ...READ MORE

May 23, 2018 in Java by code.reaper12
• 3,500 points
752 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
749 views
0 votes
1 answer

What is ?: this operator called in java ? how dose it function?

? :  is the Conditional operator and is ...READ MORE

Jun 11, 2018 in Java by sophia
• 1,400 points
749 views
0 votes
1 answer

How to get the number of digits in an int?

You can find out the length of ...READ MORE

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

How is inheritance in C++ different than that in Java?

The purpose of inheritance is same for ...READ MORE

Feb 6, 2019 in Java by Priyaj
• 58,090 points
741 views
0 votes
1 answer

java.lang.UnsupportedClassVersionError: Bad version number in .class file. How to solve this?

I've learned that error messages like this ...READ MORE

Jul 4, 2018 in Java by Annie
• 240 points
741 views
0 votes
0 answers

How to get the current London time and date using javascript

Using the code below, I attempted to& ...READ MORE

Dec 7, 2022 in Java by Nicholas
• 7,760 points
739 views
0 votes
1 answer

Java equals() vs Arrays.equals()

Here, array1.equals(array2)meansarray1 == array2 That is, it checks whether ...READ MORE

Oct 11, 2018 in Java by code.reaper12
• 3,500 points
736 views
0 votes
1 answer

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

May 25, 2018 in Java by Rishabh
• 3,620 points
736 views
0 votes
2 answers

How to find out current working directory in Java?

You can also use java.nio.file.Path and java.nio.file.Paths. Path ...READ MORE

Jul 31, 2018 in Java by Sushmita
• 6,910 points
735 views
0 votes
2 answers

Date format conversion in Java

Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); Date date = ...READ MORE

Aug 13, 2018 in Java by Sushmita
• 6,910 points
732 views
0 votes
1 answer

How can we upload the files using JSP/ Servlets in Java?

<form action="upload" method="post" enctype="multipart/form-data"> ...READ MORE

Jun 8, 2018 in Java by Sushmita
• 6,910 points
731 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
730 views
0 votes
1 answer

How to convert s Stack trace to a String?

One can use the given method to ...READ MORE

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

What is Java Enterprise Edition ?

Is Java EE just a specification? What ...READ MORE

May 14, 2018 in Java by Rishabh
• 3,620 points
722 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
721 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
715 views
0 votes
0 answers

Sort arrays of primitive types in descending order

I got a huge array of double ...READ MORE

Aug 3, 2022 in Java by krishna
• 2,820 points
714 views
0 votes
2 answers

How to move or copy a file in Java

The new JAVA Specification Request 203 -NIO will ...READ MORE

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

What is the syntax to initialize an array?

Rather than learning un-Official websites learn from ...READ MORE

Aug 2, 2018 in Java by samarth295
• 2,220 points
711 views
0 votes
1 answer

What are the different ways of comparing Strings in Java?

The different ways of comparing string in ...READ MORE

Mar 5, 2019 in Java by Wasim
709 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
708 views
0 votes
1 answer

How can I read a large text file line by line using Java?

// Open the file FileInputStream file = new ...READ MORE

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

Perform "Switch-case" on String in Java

Switches based on integers can be optimized ...READ MORE

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

Get sub-string from text based on certain conditions/rules

Hello @laiman, You can use IsMatch function that tests whether ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
701 views
0 votes
1 answer

Getting A File's Mime Type In Java

In Java 7 you can now just ...READ MORE

Dec 14, 2018 in Java by Daisy
• 8,120 points
701 views
0 votes
1 answer

How do I fix a NullPointerException?

When you declare a reference variable (i.e. ...READ MORE

Apr 13, 2018 in Java by Parth
• 4,630 points
700 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
696 views
0 votes
1 answer

Creating a JUnit Test Suite Class

To create a test suite we will use the ...READ MORE

Jan 17, 2019 in Java by Frankie
• 9,830 points
695 views
0 votes
1 answer

How can I Sort an ArrayList in Java

You can sort the ArrayList in 2 ...READ MORE

Apr 23, 2018 in Java by sharth
• 3,370 points
694 views
0 votes
1 answer

What does "javascript:void(0)" mean?

The href of the link helps with ...READ MORE

Feb 8, 2022 in Java by Rahul
• 9,670 points
692 views
0 votes
0 answers

Copy several byte arrays to one big byte array

I have several little byte arrays and ...READ MORE

Aug 18, 2022 in Java by krishna
• 2,820 points
691 views
0 votes
1 answer

what do you mean by static block in java?

Static block is used for initializing the ...READ MORE

Jun 18, 2018 in Java by scarlett
• 1,290 points
691 views
0 votes
1 answer

How to run a Java program from the command line on Windows?

Hello @kartik, In case your Java class is ...READ MORE

Apr 9, 2020 in Java by Niroj
• 82,880 points
689 views
0 votes
0 answers

How to stop timer in javascript?

I'd want to end a timer by clicking a button, but I can't figure out how.  I tried using clearInterval() to halt a timer, but I'm not sure whether it was called correctly. This is my current code. <html> <head> <title>Bootstrap</title> ...READ MORE

Dec 8, 2022 in Java by Nicholas
• 7,760 points
688 views
0 votes
1 answer

Java String interning

The String.intern() method of Java Strings ensures ...READ MORE

Oct 25, 2018 in Java by geek.erkami
• 2,680 points
688 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
684 views
0 votes
1 answer

How can I get the current stack trace in Java?

Hello @kartik, Try this: Thread.currentThread().getStackTrace(); is fine if you don't ...READ MORE

Jul 28, 2020 in Java by Niroj
• 82,880 points
683 views
0 votes
0 answers

Unscramble Letters in Java - Get all possible combinations of the letters

I am currently an AP Computer Science ...READ MORE

Apr 13, 2022 in Java by Rahul
• 3,380 points
682 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
682 views
0 votes
1 answer

How to get a platform-dependent new line character in Java?

If you are using Java 1.5 or ...READ MORE

Jul 3, 2018 in Java by Akrati
• 3,190 points
680 views