Home » featured

Tag Archives: featured

String.format Java Example

In this post, we feature a comprehensive String.format Java Example. In Java, printf is exactly like string.format, but it does not return anything, it only prints the result. We are going to see how to format Strings in Java. Developers familiar with C, will find the methods used here resembling printf function. And the formatting specifications are very similar. In ...

Read More »

Java Map Example

In this post, we feature a comprehensive Java Map Example. We will discuss about Maps in Java. A Map is an interface that maps keys to values. The keys are unique and thus, no duplicate keys are allowed. A map can provide three views, which allow the contents of the map to be viewed as a set of keys, collection ...

Read More »

ArrayList Java Example – How to use arraylist

In this example we will show how to use ArrayList in Java. The class java.util.ArrayList provides resizable-array, which means that items can be added and removed from the list by using the provided arraylist methods. It implements the List interface. A major question related to arraylists is about when to use arraylists instead of arrays and vice versa. An ArrayList ...

Read More »

Substring Java Example

In this post, we feature a comprehensive Substring Java Example. We will show how to use Java String substring() API method. 1. Syntax substring() method can be expressed in two ways: String substring(int start, int end)String substring(int start) 2. Parameters start This parameter is mandatory and it specifies the starting position of the extracted string. Note that first character of string ...

Read More »

java.lang.NullPointerException Example – How to handle Java Null Pointer Exception

In this post, we feature a comprehensive example of java.lang.NullPointerException – Java Null Pointer Exception. In Java, a special null value can be assigned to an object’s reference and denotes that the object is currently pointing to an unknown piece of data. A java.lang.NullPointerException is thrown when an application is trying to use or access an object whose reference equals to null. The following cases throw ...

Read More »