Thursday, February 12, 2015

Primitive Data Types

We have 8 primitive data type , lets explore each data types and the maximum and minimum values. -byte -short -int -long -float -double -char -boolean Lets an example with the implementation

public class PrimitiveType  {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  //primitive type data

         System.out.println("Maximum byte value "+Byte.MAX_VALUE);//maximum value a byte data type can hold.
  System.out.println("Maximum short value "+Short.MAX_VALUE);
  System.out.println("Maximum integer value "+Integer.MAX_VALUE);
  System.out.println("Maximum float value "+Float.MAX_VALUE);
  System.out.println("Maximum double value "+Double.MAX_VALUE);
  System.out.println("Maximum long value "+Long.MAX_VALUE);
  
  System.out.println("Minimum byte value "+Byte.MIN_VALUE);//minimum value a byte data type can hold.
  System.out.println("Minimum short value "+Short.MIN_VALUE);
  System.out.println("Minimum integer value "+Integer.MIN_VALUE);
  System.out.println("Minimum float value "+Float.MIN_VALUE);
  System.out.println("Minimum double value "+Double.MIN_VALUE);
  System.out.println("Minimum long value "+Long.MIN_VALUE);
  
  char ch=65;
  System.out.println(ch);
  
  boolean boolvalue=true;
  System.out.println(boolvalue);

 }

}

The Above example illustrates the different data types and how to find the min and maximum value of a particular data type. >>>to String
------------------------------------------------------------------------------------------------------------