Aside

In Java there are total 8 data types available which are further divided into 4 groups viz. integers, floating point numbers, character & boolean values.

Type

Size in Bytes (Bits)

Range

Default value

Contains

Integers
Byte 1 byte (8 bits) -128 to 127 0 Signed Integer
Short 2 bytes(16 bits) -32768 to 32767 0 Signed Integer
Int 4 bytes(32 bits) -2147483648 to 2147483647 0 Signed Integer
Long 8 bytes(64 bits) -9223372036854775808 to 9223372036854775807 0 Signed Integer
Floating point numbers
Float 4 bytes(32 bits) -3.4e38 to 3.4e38(i.e. 3.4*1017) 0.0 IEEE754 Floating point number
Double 8 bytes(64 bits) -1.7e308 to 1.7e308(i.e. 1.7*10151) 0.0 IEEE754 Floating point number
Characters
char 2 bytes(16 bits) \u0000 to \uFFFF \u0000 Unicode Characters
Boolean values
boolean 1 bit Not Applicable False true or false

Table : Data Types in Java

Data Types in Java

Aside
import java.io.*;
import java.util.*;

public class MyFileReader
{

 public static void main (String[] args)
 throws java.io.IOException
 {

  String s1;
  String s2;

  // set up the buffered reader to read from the keyboard
  BufferedReader br = new BufferedReader
 (new FileReader ("MyFileReader.txt"));

  s1 = br.readLine();

  System.out.println ("The line is " + s1);
  System.out.println
 ("The line has " + s1.length() + " characters");

  System.out.println ();
  System.out.println
 ("Breaking the line into tokens we get:");

  int numTokens = 0;
  StringTokenizer st = new StringTokenizer (s1);

  while (st.hasMoreTokens())
     {
      s2 = st.nextToken();
      numTokens++;
      System.out.println
 ("    Token " + numTokens + " is: " + s2);
     }
 }
}

My File Reader in java