Linux Distribution
Java Development Kit (JDK)
Java Runtime Environment (JRE)
A Shell Interface

My Setup:
Debian GNU/Linux

Variables are pieces of memory which can hold a value. They are used to
describe changing values of a program.

Primitive Types In Java:

  1. boolean – a variable which represents either the value true
    or false. One bit.
  2. char – a variable which represents a unicode character
  3. byte – a variable which represents an 8-bit signed integer
  4. short – a variable which represents a 16-bit signed integer
  5. int – a variable which represents a 32-bit signed integer
  6. long – a variable which represents a 64-bit signed integer
  7. float – a variable which represents IEEE 754’s floating
    point 32-bit float data type
  8. double -a variable which represents IEEE 754’s floating
    point 64-bit double data type

Along with Primitive types, there are non-primitive types.

Non Primitive Types in Java:

  1. String – a null terminating array of characters that forms words.
    (eg. “Hello” is stored as “Hello\0”)
  2. class – a data type which defines a blueprint to create a new data type.
  3. enum – a special data type used to define collections of constants.
  4. array – a collection of objects of the same type There are three types of variables when thinking of a java program:
  5. instance variables – Variables that are used to describe classes. They
    are declared within the class and are coupled to the
  6. local variables – Variables that are local are declared within methods
    to be used for computation.
  7. static variables – Variables that are labeled static do not require a
    class to be instantiated and are coupled to the class
    (rather then the object) On top of all these, you have datatype modifiers.

Datatype Modifiers:

  1. public – visible to the program
  2. protected – visible to the class and its derived classes
  3. private – visible only to the class itself
  4. abstract – a class marked as abstract
  5. final – a class marked as final can not be extended.
  public class variables{
    public static void main(String[] args){ 
      int foo;  //declares the foo integer .
      int bar = 5; //declares and defines the bar integer
      foo = 7; //defining the foo character

      byte baz = 22;
      char c = 'c'; //declaring and defining a character using single quote

      String hello = "Hello"; /*declaring and defining a
                                string using the double quote */
      boolean isRunning = true; //defining and declaring a boolean
      double pi = 3.14159; //defining a double, the natural floating type variable
      float fpi = (float)pi; //defining a float via casting .

Leave a Reply