Keywords

  • Java has a list of keywords that are predefined/reserved words.
  • Keywords cannot be used as an identifier for class, subclass, variables and methods.
  • Keywords are case sensitive.



Identifiers

  • Generally, Unique names are called as Identifiers.
  • Identifier can be variable name, method name and class name.

  • It has certain rules for identifier are

    • Names can contain letters, digits, underscores, and dollar signs

    • Names must begin with a letter

    • Names are case sensitive 

    • Names should start with a lowercase letter and it cannot contain whitespace 

    • Names can also begin with $ and _ 

    • Reserved words should not be used as names like Java keywords, such as true or boolean

    • Names should be of length 4 to 15 letters only. however, there is no limit on its length. But, it is good to follow the standard conventions. 

 Data Types

  • Data types indicates different sizes and values that can be stored in the variables

  • There are two types of data types in java

    • Primitive Data Types  - 8 Types

      • Numeric

        • Integral Group

          • byte   -  1 byte  =>  - 128 to 127

          • short  -  2 byte  =>  - 32,768 to 32767

          • int      -  4 byte  =>  - 2,147,483,648 to 2,147,483,647

          • long   -  8 byte  =>  -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

        • Floating point Group

          • float       - 4 byte   => 6 to 7 decimal digits

          • double   - 8 byte   =>  15 decimal digits

      • Non Numeric

        • boolean   -  1 bit    =>  true or false 

        • char         -  2 byte  => Single character or ASCII value

    • Non Primitive Data Types
      • String

      • objects

      • classes

      • arrays