Home » Tag Archives: featured

Tag Archives: featured

String.format Java Example

In this post, we feature a comprehensive String.format Java Example. 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 fact, PrintStream class in Java, has a member function called printf designed to work similarly with C’s printf. ...

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. 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 is a dynamic data structure so ...

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 ...

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. 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 NullPointerExceptionis thrown when an application is trying to use or access an object whose reference equals to null. The following cases throw that exception: Invoking a method from ...

Read More »