The Primitive Types : Data Type Introduction « Data Type « Java Tutorial






Java has eight primitive types of data: byte, short, int, long, char, float, double, and boolean.

These can be put in four groups:

  1. Integers includes byte, short, int, and long
  2. Floating-point numbers includes float and double
  3. Characters includes char, like letters and numbers.
  4. Boolean includes boolean representing true/false values.
byte

     The smallest integer type
     a range from -128 to 127. 
     useful when working with a stream of data from a network or file. 
     Byte variables are declared by use of the byte keyword. 

     byte b, c;

int

    The most commonly used integer type
    a signed 32-bit type 
    Ranging from -2,147,483,648 to 2,147,483,647
    used to control loops and to index arrays. 
    the most efficient type

long

   a signed 64-bit type








2.1.Data Type Introduction
2.1.1.The Primitive Types
2.1.2.Size for Java's Primitive Types
2.1.3.Default values for primitives and references
2.1.4.Literals
2.1.5.Surprise! Java lets you overflow
2.1.6.Wrapping a Primitive Type in a Wrapper Object: boolean, byte, char, short, int, long, float, double
2.1.7.Print the limits of primitive types (e.g. byte, short, int ...) in Java
2.1.8.Get the minimum and maximum value of a primitive data types
2.1.9.Shows default initial values
2.1.10.Primitive utilities
2.1.11.Return primitive type the passed in wrapper type corresponds to