Most viewed questions in Java

0 votes
1 answer

Does python have an equivalent to Java Class.forName()?

This is found in the python standard ...READ MORE

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

How can we add JTable in JPanel with null layout?

The JPanel should have some layout manager. JTable ...READ MORE

Jun 1, 2018 in Java by Parth
• 4,630 points
1,227 views
0 votes
2 answers

How can we assert, that a certain Exception is thrown in JUnit 4 tests?

@Test(expected = IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { ...READ MORE

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

How can we encrypt a String in Java?

Let's assume the bytes to encrypt are ...READ MORE

Oct 26, 2018 in Java by Sushmita
• 6,910 points
1,225 views
0 votes
2 answers

Java Environment Variables

--- To set java path --- There are ...READ MORE

Dec 3, 2018 in Java by Sushmita
• 6,910 points
1,222 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,212 views
0 votes
1 answer

Can I help with the gradle code for AspectJ?

You can go to maven repositories https://mvnrepository.com/artifact/org.aspectj/aspectjtools/1.9.2 ...READ MORE

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

HashMap vs LinkedHashMap vs TreeMap

Hi, there is no as such difference ...READ MORE

May 5, 2018 in Java by v.liyyah
• 1,300 points
1,190 views
0 votes
1 answer

which maven dependency has to be added for MongoPreparedStatement in java 1.8

You need to define the dependency of a ...READ MORE

Jul 30, 2019 in Java by Sirajul
• 59,230 points
1,186 views
0 votes
1 answer

Is Java “pass-by-reference” or “pass-by-value”?

Think of reference parameters as being aliases ...READ MORE

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

First panel added to a frame disappears

The default layout of a JFrame (or more specifically ...READ MORE

Mar 1, 2019 in Java by developer_1
• 3,320 points
1,180 views
0 votes
0 answers

I cannot build and sync my gradle in androidstudio.

how to build and sync my gradle ...READ MORE

May 8, 2020 in Java by Edureka
• 120 points
1,179 views
0 votes
1 answer

Handling empty input in swing text box

login_but.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ //System.out.print(F_user.getText()); String username ...READ MORE

Aug 27, 2019 in Java by Nila
1,176 views
0 votes
2 answers

How to convert a java string into byte array

Try using String.getBytes(). It returns a byte[] ...READ MORE

Aug 22, 2019 in Java by Sirajul
• 59,230 points
1,176 views
0 votes
1 answer

Spring AOP vs AspectJ AOP

Well, below I have listed down few ...READ MORE

Sep 10, 2018 in Java by v.liyyah
• 1,300 points
1,173 views
0 votes
1 answer

Google AJAX Libraries CDN for jQuery

The Google Hosted Libraries is a stable, ...READ MORE

May 30, 2022 in Java by gaurav
• 23,260 points
1,163 views
0 votes
0 answers

What is the difference between Default and Protected access specifiers?

Can anyone explain in brief as what ...READ MORE

Feb 6, 2019 in Java by Dishantu
1,163 views
0 votes
1 answer

Do I have download any jars related to ZeonPad or do i perfrom the above code directly in Eclipse IDE. Please guide me.

Hello @Basha.  If you are running it on ...READ MORE

Aug 21, 2019 in Java by Ramya
1,161 views
0 votes
0 answers

Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception

I am getting this exception when I ...READ MORE

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

How can we format float to n decimal places ?

You may pass the float value: String.format("%.2f", floatVal); READ MORE

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

Iterating through a Collection, avoiding ConcurrentModificationException when removing in loop

You can either use the iterator directly ...READ MORE

Jul 3, 2018 in Java by Rishabh
• 3,620 points
1,151 views
0 votes
2 answers

Why are you not able to declare a class as static in Java?

A static keyword  can be used with ...READ MORE

Jun 11, 2019 in Java by Neha
• 330 points
1,149 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
1,145 views
0 votes
1 answer

How can one detect airplane mode on Android?

Hello, When registering the Airplane Mode BroadcastReceiver (@saxos answer) I ...READ MORE

May 26, 2020 in Java by Niroj
• 82,880 points
1,144 views
+1 vote
1 answer

How to print factorial of a number using While loop?

While also works like for just you ...READ MORE

Nov 22, 2018 in Java by Namitha
1,139 views
0 votes
1 answer

Remote debugging a Java application

I noticed that some people are cutting ...READ MORE

Oct 16, 2018 in Java by Sushmita
• 6,910 points
1,138 views
0 votes
2 answers

What is the difference between = and equals()?

The equals() method compares the "value" inside String instances ...READ MORE

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

Generating an MD5 hash?

The MessageDigest class can provide you with an instance ...READ MORE

Jun 13, 2018 in Java by Rishabh
• 3,620 points
1,131 views
0 votes
1 answer

Various Advice in Spring AOP

Below are the various advices available in AOP: Before: These types ...READ MORE

Sep 12, 2018 in Java by geek.erkami
• 2,680 points
1,128 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,910 points
1,125 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,119 views
0 votes
2 answers

Store String inside a File using Java

We can use Apache Commons IO. It ...READ MORE

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

How to specify the certificate to use for authenticating the server to client?

You can try the command given below. System.setProperty("javax.net ...READ MORE

Jan 2, 2019 in Java by Daisy
• 8,120 points
1,108 views
0 votes
1 answer

How to get current formatted date dd/mm/yyyy in Javascript and append it to an input

The stringent equality operator (===) works exactly like the abstract equality operator (==), with the exception that no type conversion is performed, and the types must be the same to be regarded equal. Javascript Tutorial on Comparison Operators After performing any required type transformations, the == operator will check for equality.  Because the === operator does not perform the conversion, it will simply return false if two values are not of the same type.  Both are equally fast. "abc" == new String("abc") ...READ MORE

Nov 4, 2022 in Java by Damonlang
• 700 points
1,106 views
0 votes
1 answer

What is the reason for no ConcurrentHashSet against ConcurrentHashMap?

Hello, There's no built in type for ConcurrentHashSet because you ...READ MORE

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

How can we activate JMX on my JVM for access with jconsole?

Hello @kartik, Run your java application with the ...READ MORE

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

Getting a File's MD5 Checksum in Java

There's an input stream decorator, java.security.DigestInputStream, so that ...READ MORE

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

How can I run test methods in specific order in JUnit4?

@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SampleTest { ...READ MORE

Jan 7, 2019 in Java by Daisy
• 8,120 points
1,079 views
+2 votes
1 answer

please someone tell the code to launch an instance in digital ocean using java

In order to create a digital ocean ...READ MORE

Jan 14, 2020 in Java by Sirajul
• 59,230 points
1,076 views
0 votes
1 answer

Swing Java create Text Box

In the frame, you can use the ...READ MORE

Aug 27, 2019 in Java by Kyle
1,071 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,910 points
1,070 views
+1 vote
1 answer

Can you please explain the difference between string, string buffer and string builder?

String are immutable where as StringBuffer and ...READ MORE

Jul 5, 2019 in Java by Akash
• 160 points
1,067 views
0 votes
2 answers

How can we convert java.util.Date to java.sql.date in Java?

It's easy to convert a java.util.Date object ...READ MORE

Aug 27, 2019 in Java by Sirajul
• 59,230 points
1,063 views
0 votes
1 answer

Non-static method within Static method in Java

As per my knowledge, you are getting this error ...READ MORE

Sep 28, 2018 in Java by anto.trigg4
• 3,440 points
1,052 views
0 votes
1 answer

Check if input is number or letter javascript

The isNaN function can be used to ...READ MORE

Nov 15, 2022 in Java by Damonlang
• 1,230 points
1,050 views
0 votes
1 answer

How to get text from text box in Swing?

You can add a Button listener here. ...READ MORE

Aug 27, 2019 in Java by Jishan
1,050 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,050 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

May 10, 2018 in Java by Rishabh
• 3,620 points
1,048 views
0 votes
0 answers

keytool error Keystore was tampered with, or password was incorrect

When I generate certificates on my local ...READ MORE

May 19, 2022 in Java by Kichu
• 19,050 points
1,046 views