Primitive Data Types

     
      There are 8 Primitive data Types,
  • byte - Integers
  • char - Integers 
  • short - Integers
  • int - Integers
  • long - Integers
  • float - Floating Point -- Decimal places
  • double - Floating Point -- Decimal places
  • Boolean - Binary -- 2 Options -- In java -- True or False

      Refer the following, 
      
      int a = 5;
      long b = 7;
      a + b;

      Is this statement true?
      Yes its true, because both of them are in the type of Integers.

   
      float c = 7.8;
      double d = 5;
      c + d;

       Is this statement true?
       Yes its true, because both of them are in the type of Decimal points.


       long e = 12345;
       float c =  34.87;
       e + f;

      Is this statement true?
      No its false, because they are not in the same type.

  • We cant deal with premitive data types in different types only with the same type one's, we can deal.

       Integer (Hierarchy/ Ascending order)
  1. long
  2. int
  3. short
  4. char 
  5. byte
   
       Floating (Hierarchy/ Ascending order)
  1. double
  2. float

-(8th Article)        
                                                                                                    


Thank You!
                                                                                                           


                                                                                                            
                     
                                                                                                       -Article about Java by Hirun Yapa



 









Comments

Popular posts from this blog

Interfaces

Super Keyword

Abstract Classes