TYPES in Java (Data Types) (#2)

Java data types can be categorised into "Fundamental type" and "Reference type".

-----------------Fundamental types----------------
  • byte   (8 bit, -128 to 127)
  • short  (16 bit, -32768 and 32767)
  • int    (32 bit)
  • long   (64 bit)
  • float  (32 bit)
  • double (64 bit)
  • char   (16 bit, 0 to 65535)
  • boolean(1 bit, true or false)

Description:
Fundamental types are like LEGO blocks, using which you can create VARIABLES in your program.

VARIABLES are use to store value (state) of the property during the Application RUN TIME, e.g. price variable can store value of price for the specific Car instance (Object).

-----------------Reference types------------------
  • String
  • Array
  • Objects (including user defined data types such as Car)
Description:
Reference types are build from the Fundamental types or from other Reference types.
Below Reference type Car built from the combination of Fundamental type (double) and Reference type (Engine).

public class Car {
     private double price;
     private String currency;
}

No comments :

Post a Comment