Most viewed questions in Java

0 votes
1 answer

Error:java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Hello @kartik, This error means you're trying to ...READ MORE

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

How to round a number to n decimal places in Java?

Use setRoundingMode, set the RoundingMode explicitly to handle your issue ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points

edited Jul 6, 2023 by Khan Sarfaraz 1,400 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,910 points
1,395 views
0 votes
1 answer

__proto__ VS. prototype in JavaScript

To answer your query, the __proto__ is ...READ MORE

Feb 22, 2022 in Java by Aditya
• 7,680 points
1,393 views
0 votes
1 answer

what is the extension of compiled java classes?

The extension of compiled Java classes is ...READ MORE

Oct 17, 2023 in Java by anonymous
• 520 points
1,390 views
0 votes
1 answer

Java 8 List<V> into Map<K, V>

Based on Collectors documentation it's as simple as: Map<String, Choice> result ...READ MORE

Nov 29, 2018 in Java by Daisy
• 8,120 points
1,383 views
0 votes
1 answer

What is the difference between package private, public, protected?

Modifier Class Package Subclass World Public Y Y Y Y Protected Y Y Y N No modifier Y Y N N private Y N N N   Public: Any package, any class accessibility is ...READ MORE

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

How to Embed Gecko/WebKit in Java?

Hii, If SWT is an option, you can ...READ MORE

May 8, 2020 in Java by Niroj
• 82,880 points
1,377 views
0 votes
1 answer

Getting "Unsupported major.minor version" error.

I will recommend not to upgrade the ...READ MORE

Feb 22, 2019 in Java by Sapan
1,374 views
0 votes
0 answers

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path [duplicate]

I have a project created by Maven ...READ MORE

Apr 21, 2022 in Java by Rahul
• 3,380 points
1,369 views
0 votes
1 answer

Count occurance of string in an array

You can use hashmap to solve this, ...READ MORE

Mar 7, 2019 in Java by Priyaj
• 58,090 points
1,369 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,363 views
0 votes
0 answers

send images on whatsapp web with javascript DOM

I currently have the script that delivers ...READ MORE

Sep 28, 2022 in Java by Nicholas
• 7,760 points
1,361 views
0 votes
1 answer

Sending POST data in Android

public class CallAPI extends AsyncTask<String, String, String> ...READ MORE

Nov 28, 2018 in Java by Sushmita
• 6,910 points
1,355 views
0 votes
1 answer

How to import android project as library and NOT compile it as apk?

Hello, In projLib's build.gradle file, you'll see a statement ...READ MORE

May 26, 2020 in Java by Niroj
• 82,880 points
1,354 views
0 votes
1 answer

How can I set JFrame to appear centered, regardless of monitor resolution?

Hello @kartik, Use setLocationRelativeTo(null) This method has a special effect ...READ MORE

Apr 21, 2020 in Java by Niroj
• 82,880 points
1,350 views
0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

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

How to split Strings by space in Java ?

You can use split() method. str = "Hello ...READ MORE

May 16, 2018 in Java by sharth
• 3,370 points
1,334 views
0 votes
2 answers

How to call one constructor from another in Java?

public class Cons { public static Cons ...READ MORE

Jul 24, 2018 in Java by Akrati
• 3,190 points
1,330 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,120 points
1,325 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,315 views
0 votes
0 answers

How to decode jwt token in javascript without using a library?

How can I decode the payload of ...READ MORE

Apr 21, 2022 in Java by Rahul
• 3,380 points
1,314 views
0 votes
2 answers

How to round any number to n decimal places in Java?

new BigDecimal(String.valueOf(double)).setScale(yourScale, BigDecimal.ROUND_HALF_UP); will get you a BigDecimal. To ...READ MORE

Aug 26, 2019 in Java by Sirajul
• 59,230 points
1,310 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,306 views
0 votes
0 answers

Iterate over json and output multiple rows

I have a json in which multiple ...READ MORE

Mar 12, 2019 in Java by Yogesh
1,303 views
0 votes
1 answer

jQuery AJAX submit form

There is a simple input mentioned below ...READ MORE

Feb 8, 2022 in Java by Soham
• 9,700 points
1,302 views
0 votes
1 answer

How to stop the Thread in Java?

Use a flag, which will indicate the ...READ MORE

Jun 11, 2018 in Java by Parth
• 4,630 points
1,294 views
0 votes
1 answer

How to read and write on an excel files?

Follow these steps: Write: public class User { ...READ MORE

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

How to convert Java String into byte[]?

The object your method decompressGZIP() needs is a byte[]. So the ...READ MORE

Dec 30, 2020 in Java by Gitika
• 65,910 points
1,291 views
0 votes
0 answers

java regex split string into double numbers and-letters

I am having a problem splitting something ...READ MORE

Nov 14, 2019 in Java by khs
• 120 points
1,291 views
0 votes
1 answer

System.exit() method in Java

System.exit() is a method of System class ...READ MORE

Sep 28, 2018 in Java by code.reaper12
• 3,500 points
1,291 views
0 votes
1 answer

How can I make my output float when my two integers are integer?

Hi Prapti , I got your doubt please check ...READ MORE

Jun 3, 2019 in Java by sampriti
• 1,120 points
1,289 views
0 votes
1 answer

How to disable session in JSP?

<%@ page session=“false” %>    Using this above command, you can ...READ MORE

Feb 18, 2019 in Java by Frankie
• 9,830 points
1,284 views
0 votes
1 answer

Architecture mismatch between driver and application

None of these did it for me. ...READ MORE

Feb 6, 2019 in Java by developer_1
• 3,320 points
1,280 views
0 votes
1 answer

How to make JTable both AutoResize and horizontall scrollable?

Hello @kartik, If for some reason customising JTable ...READ MORE

Apr 21, 2020 in Java by Niroj
• 82,880 points
1,272 views
0 votes
1 answer

How to call setUndecorated() after a frame is made visible?

Hello kartik, You can Try: dispose(); setUndecorated(true); setVisible(true); Check it Out. Hope ...READ MORE

Apr 21, 2020 in Java by Niroj
• 82,880 points
1,271 views
0 votes
2 answers

Remove duplicate elements from an ArrayList in Java

List<String> al = new ArrayList<>(); // add elements ...READ MORE

Jul 26, 2018 in Java by Sushmita
• 6,910 points
1,267 views
0 votes
1 answer

To use JavaMail API for sending mails in Android without using the default/built-in App

ADD 3 jars found in the following ...READ MORE

Jun 6, 2018 in Java by sridhar
• 160 points
1,266 views
0 votes
1 answer

What is the extension of java code files?

Java source code files often have the ...READ MORE

Oct 11, 2023 in Java by anonymous
• 3,320 points
1,263 views
0 votes
0 answers

I need to Post api to database using java in intellij. After testing sample api through postman i got an Sql exception saying Syntax error at or near ',' Please tell me where i made a mistake

public Result setModelMasterParams(){         try{             long tenantId = request().getHeader("tenant_id")==null                     || request().getHeader("tenant_id").equalsIgnoreCase("")                     || ...READ MORE

Aug 19, 2020 in Java by Sriram
• 120 points

recategorized Aug 19, 2020 by Niroj 1,263 views
0 votes
1 answer

How to open warning/information/error dialog in swing?

Hello, You can try out : import javax.swing.JFrame; import javax.swing.JOptionPane; public ...READ MORE

Apr 21, 2020 in Java by Niroj
• 82,880 points
1,260 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,257 views
0 votes
1 answer

Sort ArrayList of custom Objects by property

Since Date implements Comparable, it has a compareTo method just like String does. So your ...READ MORE

Dec 22, 2020 in Java by Gitika
• 65,910 points
1,255 views
0 votes
1 answer

Exception coming "android.os.NetworkOnMainThreadException"

This exception is thrown when an application ...READ MORE

Jun 6, 2018 in Java by poorvi
• 160 points
1,250 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,250 views
0 votes
1 answer

Implement Tree(Datastructure) in Java

I wrote a small "TreeMap" class based ...READ MORE

May 9, 2018 in Java by sharth
• 3,370 points
1,249 views
0 votes
1 answer

how to play sound in java?

 The following code will work fine. But I ...READ MORE

Jun 20, 2018 in Java by scarlett
• 1,290 points
1,247 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,236 views
0 votes
1 answer

How is the array's address stored in memory?

In terms of memory, you have continuous blocks ...READ MORE

Nov 23, 2018 in Java by Namitha
1,234 views
+1 vote
1 answer

How to find even or odd using call by value?

Call by value is, when a primitive ...READ MORE

Nov 23, 2018 in Java by Namitha
1,231 views