Core java
- 05 October
Calculate total surface area of Hemisphere in java
In this post, we will see how to calculate total surface area of Hemisphere in java. Hemisphere is exactly half of sphere. There can be many practical examples of Hemisphere. You can divide earth into two hemisphere i.e. Northen Hemisphere and Southern Hemisphere. Formula of calculating total surface area of Hemisphere is: surface area of […]
- 05 October
Get Random Number between 0 and 1 in Java
In this post, we will see how to get random number between 0 to 1 in java. We have already seen random number generator in java. Get Random Number between 0 and 1 in Java We can simply use Math.random() method to get random number between 0 to 1. Math.random method returns double value between […]
- 05 October
Print prime numbers from 1 to 100 in java
In this program, we will print prime numbers from 1 to 100 in java. A prime number is a number which has only two divisors 1 and itself. To check if the number is prime or not, we need to see if it has any other factors other than 1 or itself. If it has, […]
- 05 October
java.lang.NumberFormatException
In this post, we will see about Java.lang.NumberFormatException. java.lang.NumberFormatException occurs where you try to convert any non-numeric String to Number such as Integer, Double, Float or Long. This exception generally occurs when you get input from user in the form of String. This is not Java developer‘s fault and mostly data error. In this scenario, […]
- 15 September
What are Xmx and Xms parameters in java
In this post, we will see about Xms and Xmx parameter in java. -Xmx specifies maximum memory size for Java virtual machine (JVM), while -Xms specifies the initial memory size. It means JVM will be started with Xms amount of memory and JVM will be able to use maximum of JVM amount of memory. Let’s […]
- 25 July
Validate phone number in java
In this post, we will see how to validate phone number in java. Validate any international phone number as per E.123 E.123 is a standards-based recommendation by the International Telecommunications Union sector ITU-T. E.123 provides following specifications. The leading plus (+) serves as an international prefix symbol, and is immediately followed by the country code […]
- 16 July
Garbage Collection in java
In this post, we will see about Garbage Collection in java. I will try to explain with the help of diagrams and examples rather than theory. JVM Memory is divided into three parts Young generation Old generation Metaspace (Perm Gen) Young Generation As the name suggests, young generation is the area where newly created objects […]
- 11 July
Validate email address in java
In this post, we will see how to validate email address in java. There are times when you have to validate email address provided by user. You might want to write your own logic to validate email addresses but there are lots of standard regular expressions or libraries which can help you validate email address […]
- 29 May
How to print even and odd numbers using threads in java
In this post, we will see how to print even and odd numbers using threads in java. see also: How to print sequence using 3 threads in java Problem You are given two threads. You need to print odd numbers using one thread and even numbers using another thread.You need to print in natural order […]