Trending questions in Java

0 votes
1 answer

simple HTTP server in Java using only Java SE API

The com.sun.net.httpserver solution is not portable across JREs. Its ...READ MORE

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

How to convert a date string to a DateTime object using Joda Time library?

DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); DateTime dt = ...READ MORE

Jan 9, 2019 in Java by Daisy
• 8,120 points
1,976 views
0 votes
2 answers

How can I invoke a method when the method name is in the form of a given string?

You could probably use method invocation from reflection: Class<?> ...READ MORE

Aug 19, 2019 in Java by Sirajul
• 59,230 points
2,665 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
756 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,077 views
0 votes
1 answer

Why Object is Super Class in Java?

Object is an exception to the first rule, ...READ MORE

Feb 7, 2019 in Java by Dheeraj
656 views
0 votes
1 answer

Aligning Diagram in Java

Without any evidence otherwise, I'd guess you've over-ridden the paint method ...READ MORE

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

Evaluating a math expression given in string form

import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; public class Test { ...READ MORE

Oct 12, 2018 in Java by Daisy
• 8,120 points
5,664 views
0 votes
1 answer

web.xml file is missing in my eclipse IDE

Very simple. You will find Deployment Descriptor ...READ MORE

Nov 27, 2018 in Java by Omkar
• 69,230 points
3,653 views
0 votes
1 answer

Why clone() method is protected in Java?

The clone() is protected because it is ...READ MORE

Nov 13, 2018 in Java by geek.erkami
• 2,680 points
4,270 views
0 votes
1 answer

$ in a variable name in Java

Java compiler uses "$" symbol internally to decorate ...READ MORE

Oct 10, 2018 in Java by code.reaper12
• 3,500 points
5,731 views
0 votes
2 answers

Unfortunately MyApp has stopped. How do I solve this?

The common solution for solving App has ...READ MORE

Mar 6, 2019 in Java by AllisonE
• 180 points
797 views
0 votes
1 answer

Static Map initialization in Java

I would suggest you to use the ...READ MORE

May 4, 2018 in Java by Akrati
• 3,190 points
12,522 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,189 views
0 votes
1 answer

Sending Email in Android using JavaMail API without using the default/built-in app

Send e-mail in Android using the JavaMail ...READ MORE

Dec 4, 2018 in Java by Daisy
• 8,120 points
3,221 views
0 votes
2 answers

how to increase heap size in java?

Here is how you can increase the ...READ MORE

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

String related Hash Functions

Usually hashes wouldn't do sums, otherwise stop and pots will have ...READ MORE

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

String mapping without Case-Sensitivity

Yes, contains is case sensitive. You can ...READ MORE

Feb 5, 2019 in Java by developer_1
• 3,320 points
473 views
+2 votes
1 answer

How to import an existing x509 certificate and private key in Java keystore to use in SSL?

keytool does not provide such basic functionality ...READ MORE

Dec 19, 2018 in Java by Daisy
• 8,120 points
2,419 views
0 votes
2 answers

Get all the permutations of a string in Java

You could use recursion to do this.  Try ...READ MORE

Aug 21, 2019 in Java by Sirajul
• 59,230 points
1,936 views
0 votes
2 answers

Is there any way to declare an array in-line?

Another way to do that, if you ...READ MORE

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

How do I get the current date and time using Java?

If you require a time stamp in ...READ MORE

Aug 23, 2019 in Java by Sirajul
• 59,230 points
2,423 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,228 views
0 votes
2 answers

Reserving space for a heap object

Run the JVM with -XX:MaxHeapSize=512m (or any big number ...READ MORE

Aug 26, 2019 in Java by Sirajul
• 59,230 points
1,011 views
0 votes
2 answers

How to parse/format dates with LocalDateTime? (Java 8)

Converting LocalDateTime to Time Zone ISO8601 String LocalDateTime ...READ MORE

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

How to resolve the error: could not find or load main class?

If you are getting error: could not ...READ MORE

May 28, 2018 in Java by Parth
• 4,630 points
10,923 views
+1 vote
2 answers

Is there a code to find 64-bit JVM or 32-bit JVM (from within a program)?

Do I need to understand the difference ...READ MORE

Jun 11, 2019 in Java by Jim
• 810 points
2,057 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
724 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,088 views
0 votes
1 answer

How can we override back button to act like home button?

Most of the time you need to ...READ MORE

Dec 14, 2018 in Java by Daisy
• 8,120 points
2,052 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

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

How to determine day of week by passing specific date?

You can use java.util.Calendar: Calendar c = Calendar.getInstance(); c.setTime(yourDate); int dayOfWeek ...READ MORE

Oct 30, 2018 in Java by Daisy
• 8,120 points
3,960 views
0 votes
2 answers

How to play .mp3 and .wav in Java?

We can use Java API to play ...READ MORE

Dec 7, 2018 in Java by Sushmita
• 6,910 points
5,520 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,116 views
0 votes
2 answers

Does Java thread.sleep() puts swing ui to sleep?

You are correct about the code putting ...READ MORE

Oct 24, 2018 in Java by Sushmita
• 6,910 points
4,682 views
0 votes
2 answers

How can I split the String with any whitespace character as delimiter?

String string = "Today's weather"; String[] arrayOfString = ...READ MORE

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

Where is JAVA_HOME on macOS Mojave (10.14) to Lion (10.7)?

export JAVA_HOME="$(/usr/libexec/java_home -v 1.6)" or export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)" or export ...READ MORE

Dec 4, 2018 in Java by Daisy
• 8,120 points
2,327 views
0 votes
1 answer

Difference between FetchType LAZY and EAGER in Java Persistence API?

Sometimes you have two entities and there's ...READ MORE

Dec 5, 2018 in Java by Daisy
• 8,120 points
2,257 views
0 votes
1 answer

Ways to compare String Values

== compares object references, it checks to see ...READ MORE

Jan 14, 2019 in Java by developer_1
• 3,320 points
490 views
0 votes
1 answer

If The A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed In Java Programming?

A class that is declared without any ...READ MORE

Nov 28, 2018 in Java by Frankie
• 9,830 points
2,504 views
0 votes
1 answer

Unable to Run the .java file

You have to enter the commands as ...READ MORE

Jan 11, 2019 in Java by Omkar
• 69,230 points
619 views
0 votes
1 answer

Exception Handling: “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it

Iterator<String> iter = myArrayList.iterator(); while (iter.hasNext()) { ...READ MORE

Jan 10, 2019 in Java by Sushmita
• 6,910 points
601 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
782 views
0 votes
0 answers

Can anyone explain Autowiring in Spring ?

Say I have a service class called UserServiceImpl that ...READ MORE

Jan 11, 2019 in Java by Sushmita
• 6,910 points
520 views
0 votes
3 answers

Is it possible to take char input from scanner?

// Use a BufferedReader to read characters ...READ MORE

Sep 7, 2018 in Java by Daisy
• 8,120 points
8,654 views
0 votes
1 answer

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

May 25, 2018 in Java by geek.erkami
• 2,680 points
10,379 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,327 views
0 votes
1 answer

Using Jackson to deserialise an array of object

First create a mapper : import com.fasterxml.jackson.databind.ObjectMapper;// in ...READ MORE

Sep 26, 2018 in Java by Sushmita
• 6,910 points
4,990 views
+1 vote
2 answers

What is an Object?

Hey @preetiagarwal, your description is an answer ...READ MORE

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

Comparing Functions in Java

I would suggest that Version 1 is ...READ MORE

Jan 9, 2019 in Java by developer_1
• 3,320 points
374 views