Home » Java Basics » data types

data types

Java Enumeration example

In this tutorial we will discuss about enumerations in Java. The Java programming language contains the enum keyword, which represents a special data type that enables for a variable to belong to a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. The values defined inside an enum are ...

Read More »

Java Dictionary example

In this tutorial we will discuss about dictionaries in Java. A Dictionary is an abstract class that maps keys to values. Every key is associated with a unique value and key are unique. Any non-null object can be used for either a key or a value. An attempt to insert either a null key or a null value to a ...

Read More »

Java Calendar example

In this tutorial we will discuss about Java’s java.util.Calendar and how to use it. The Calendar is an abstract class that provides methods for converting between time and calendar fields. Also, the class provides fields and methods for implementing a concrete calendar system. The Calendar field values can be set by calling the following methods: set, add and roll. In ...

Read More »

Java convert int to string Example

Integer to String conversion is a basic task in many Java projects. There are many ways to parse from int to string, where some of them are very simple. In this example we will show all the possible ways to convert int to string.             1. Syntax of Integer.toString() method There are two different expressions ...

Read More »

short

In this example we shall show you how to use a short type in Java. The short data type is a 16-bit signed two’s complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive).  To create a variable of short type you can just use the short keyword in the variable, as described in the code ...

Read More »

long

With this example we are going to demonstrate how to use a long type in Java. The long data type is a 64-bit signed two’s complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided by int. In short, ...

Read More »

int

This is an example of how to use an int type in Java. The int data type is a 32-bit signed two’s complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason to choose something else. This data ...

Read More »

float

In this example we shall show you how to use a float type in Java. The float data type is a single-precision 32-bit IEEE 754 floating point. Use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, ...

Read More »

double

With this example we are going to demonstrate how to use a double type in Java. The double data type is a double-precision 64-bit IEEE 754 floating point. For decimal values, this data type is generally the default choice. This data type should never be used for precise values, such as currency. In short, to create a variable of double ...

Read More »

char

This is an example of how to use a char type in Java. The char data type is a single 16-bit Unicode character. It has a minimum value of ‘\u0000’ (or 0) and a maximum value of ‘\uffff’ (or 65,535 inclusive). In order to create variable of char type you should type the char keyword in a variable. Let’s take ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns