Most viewed questions in Java

0 votes
1 answer

Sorted array is being processed faster than unsorted array. Why is it so ?

What is Branch Prediction? Consider a railroad junction: Image by ...READ MORE

Apr 18, 2018 in Java by Rishabh
• 3,620 points
947 views
0 votes
1 answer

Difference between Instance Variable and Class Variable

A variable defined within a block or ...READ MORE

Mar 12, 2019 in Java by Reema
945 views
0 votes
1 answer

How to add tabs to JTabbedPane using WindowBuilder?

Hii, You can just find out by given ...READ MORE

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

How to implement draggable tab using Java Swing?

Hello kartik, setAcceptor(TabAcceptor a_acceptor) should let the consumer code ...READ MORE

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

How to connect Java to MySql Database?

This will work: try { ...READ MORE

Aug 27, 2019 in Java by John
937 views
0 votes
1 answer

How to fire and handle HTTP requests

There are 2 options you can go ...READ MORE

Jun 13, 2018 in Java by Rishabh
• 3,620 points
936 views
0 votes
0 answers

how to solve thread-cannot find symbol

Feb 11, 2019 in Java by anonymous
933 views
0 votes
2 answers

How to sort array in descending order

there are some traditional ways that you ...READ MORE

Jul 4, 2018 in Java by Priyaj
• 58,090 points
933 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
930 views
0 votes
1 answer

Error:“java.lang.OutOfMemoryError: Java heap space” ?

Hii, Possible causes: Simple configuration issue, where the specified ...READ MORE

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

what are the ways in which a list can be iterated

  There are 5 ways to iterate over ...READ MORE

Apr 23, 2018 in Java by sharth
• 3,370 points
928 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,910 points
926 views
0 votes
1 answer

How to divide a string in two parts

String s="yourstring"; boolean flag = true; for(int i=0;i<s.length();i++) { ...READ MORE

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

Why do we use threads in Java?

Reasons for using Multithreading in Java: When a ...READ MORE

Nov 2, 2018 in Java by nsv999
• 5,500 points
924 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
923 views
0 votes
1 answer

Default Constructor in Java

Well, none of these is the default ...READ MORE

Jun 19, 2018 in Java by geek.erkami
• 2,680 points
922 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,910 points
920 views
0 votes
1 answer

Merge two array in Java

This is very simple, you need an ...READ MORE

Mar 11, 2019 in Java by Esha Gupta
915 views
0 votes
1 answer

What do you mean by Socket Programming?

Socket programming is a way of connecting two ...READ MORE

Jul 14, 2019 in Java by Frankie
• 9,830 points
914 views
0 votes
1 answer

What is the difference between Runnable and extends Thread

Runnable is the preferred way to create ...READ MORE

May 1, 2018 in Java by sharth
• 3,370 points
911 views
+1 vote
1 answer

how to print this statement in java print(' '*(r-x-1)+'*'*(2*x+1)) ( logic used in python .its perfect) but java wrong output came

In ' '*(r-x-1) and '*'*(2*x+1), you used multiplication ...READ MORE

Dec 22, 2019 in Java by Utsab Bandyopadhyay
910 views
0 votes
1 answer

Is there any difference between ConcurrentHashMap and Collections.synchronizedMap?

ConcurrentHashMap: It allows concurrent modification of the ...READ MORE

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

Can Abstract Class have a Constructor?

Yes, an abstract class can have a ...READ MORE

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

java path not found in window 7

Hey, You can follow these few steps: From the ...READ MORE

Apr 3, 2020 in Java by Gitika
• 65,910 points
907 views
0 votes
1 answer

How do I break out of nested loops in Java?

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

Mar 13, 2019 in Java by trisha
907 views
0 votes
1 answer

What is composition in Java?

Composition is again specialized form of Aggregation ...READ MORE

Feb 18, 2019 in Java by Neha
• 6,300 points

edited Feb 18, 2019 by Neha 906 views
+4 votes
1 answer

How to print the individual occurance of elements in Java?

You can use a HashMap to serve ...READ MORE

Dec 4, 2018 in Java by Priyaj
• 58,090 points
901 views
0 votes
1 answer

How to run the JAR files in windows?

Following are the steps to run the ...READ MORE

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

Create Buttons in Java Swing

First, you will have to create a ...READ MORE

Aug 27, 2019 in Java by Esha
898 views
0 votes
1 answer

In which class is the "length" property of array defined ?

It's defined in the Java language specification: The members ...READ MORE

May 8, 2018 in Java by Rishabh
• 3,620 points
897 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,360 points
896 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
894 views
0 votes
1 answer

difference between wait() and sleep() in java

We can find a big difference between ...READ MORE

Apr 26, 2018 in Java by developer_1
• 3,320 points
885 views
+1 vote
3 answers

How to convert a List to an Array in Java?

Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE

Aug 7, 2018 in Java by Akrati
• 3,190 points
884 views
0 votes
1 answer

What is object cloning in Java?

Object cloning means to create an exact ...READ MORE

Nov 29, 2018 in Java by Frankie
• 9,830 points
881 views
0 votes
3 answers

How to sort an array in java?

import java.util.Arrays; public class Sort { ...READ MORE

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

How to change selection listener in JComboBox?

It should respond to ActionListeners, like this: combo.addActionListener (new ...READ MORE

Nov 15, 2018 in Java by Frankie
• 9,830 points
876 views
0 votes
1 answer

How can I check for "undefined" in JavaScript?

If you are interested in finding out ...READ MORE

Feb 22, 2022 in Java by Aditya
• 7,680 points
872 views
+1 vote
1 answer

Program for nth prime number without using scanner

Hi @Sneha, you could use something like ...READ MORE

Jan 13, 2020 in Java by Kalgi
• 52,360 points
872 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

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

Is it possible to upload a file from desktop to web using Selenide?

Hi, @Nikhil, Yes it's possible to drop a ...READ MORE

Dec 16, 2020 in Java by Gitika
• 65,910 points
869 views
0 votes
2 answers

What are all the different ways to create an object in Java?

There are different ways you could do this ...READ MORE

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

How to encode data using Base64 in Java?

import org.apache.commons.codec.binary.Base64; We can not use sun.* packages ...READ MORE

May 30, 2018 in Java by Sushmita
• 6,910 points
866 views
0 votes
0 answers

How to convert an Object {} to an Array [] of key-value pairs in JavaScript

I'd want to transform the following object: {"1":5,"2":7,"3":0,"4" ...READ MORE

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

Static methods can't be abstract in Java

Well, Java doesn't allow this because of ...READ MORE

Oct 12, 2018 in Java by v.liyyah
• 1,300 points
865 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
862 views
0 votes
2 answers

Integer to String conversion in java

We can do this in 2 ways: String ...READ MORE

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

How to get the windows native look in Java GUI programming?

Hello Kartik,  You can try the syntax: UIManager.setLookAndFeel(PLAF); (Pluggable ...READ MORE

May 7, 2020 in Java by Niroj
• 82,880 points
854 views
0 votes
2 answers

Reading an InputStream & coverting it into a String in Java?

Apache Commons allows: String myString = IOUtils.toString(myInputStream, "UTF-8"); And ...READ MORE

Aug 30, 2019 in Java by Karan
• 19,610 points
850 views