Category Java

Wrapper Classes in Java (with Examples)

Wrapper classes in Java

A class that wraps a primitive data type into an object is called wrapper class in Java. In simple words, wrapper class provides a mechanism to convert primitive data type value into an object and vice-versa. For example, wrapping int…

Java Calendar Class

Calendar class in Java is an abstract super class that is designed to support different kinds of calendar systems. It is used to know system data and time information. Java Calendar class provides some specific functionality that is common to…

StringTokenizer in Java

How StringTokenizer works in Java

StringTokenizer in Java is a utility class that breaks a string into pieces or multiple strings called “tokens”. For example, strings separated by space and tab characters are tokens. These tokens are separated with the help of a delimiter. A…

Comparator in Java

Comparator interface in Java

Comparator in Java is an interface whose task is to compare objects of a user-defined class when the class does not implement the Comparable interface. In other words, Java Comparator is used when: Objects to be ordered do not have…

Comparable Interface in Java

Comparable interface in Java

Comparable interface in Java defines compareTo() method for comparing objects of the same type. In other words, comparable interface defines a standard way in which two objects of the same class will be compared. It is mainly used to provide…