Core java
05 Octoberjava.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 SeptemberWhat 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 JulyValidate 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 JulyGarbage 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 JulyValidate 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 MayHow 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 […]
15 MayJava LocalDateTime to Date
In this post, we will see how to convert LocalDateTime to Date. Java 8 has introduced a lot of new APIs for Date and time. There can be many ways to convert Java LocalDateTime to date. Using Instant object You can convert LocalDateTime to date using Instant object which we can from ZonedDateTime. Here is […]
09 MayFileNotFoundException in Java
In this post, we will see about FileNotFoundException in java. FileNotFoundException is thrown by constructors of FileInputStream, FileOutputStream, RandomAccessFile when file is not found on specified path. Exception can also be raised when file is inaccessible for some reason.For example: When you do not have proper permissions to read the files. FileNotFoundException is checked exception […]
04 MayHow HashMap works in java
Most common interview questions are <code>How HashMap works in java</code>, “How get and put method of HashMap work internally”. Here I am trying to explain internal functionality with an easy example. [crayon-6a294f56ea0a5931120234-i/]Â is one of the most used Collections in java.Rather than going through theory, we will start with example first, so that you will […]