Monday, April 7, 2014

Basic Java Language Fundamentals.

Tokens
Tokens are low level elements of any language and using tokens higher level constructs are build.
Ex :numbers, identifiers,special characters and operators are the example of tokens and using this we build classes,methods, expressions.

Identifiers:
Its just a name with some convention, used to denote classes,methods,variables and labels.
The first character must be always must be a letter, underscore(_) or currency symbol like dollar($).

Keywords
keywords means reserved words in java that can not be used to denote another entities. ex: final,abstract,package,public,private....so on...

Literals
It represents constant value , its value can not be changed once that is assigned to an literal.
it represents boolean , character , numeric and string values.


A Unicode character can always be specified as a four digit hexadecimal number (i.e., 16 bits) with the prefix \u.









Escape sequence
It defines special characters,that can be single-quoted to define character literals.


Note : the character literals '\t' and '\u0009' are equivalent.

the character literals '\u000a' and '\u000d' should not be used to represent newline and carriage return in the source code. These values are interpreted as line-terminator characters by the compiler, and will cause compile time errors.







Primitive data types
Three main categories :
  1. Integral types : signed integers ( byte ,int, short, long) , unsigned(char)
  2. Floating -point types: fractional signed numbers (float, double)
  3. boolean type : represent logical values( true and false)
Integer Primitive Data Types :

Their values are signed integers represented by 2’s complement






The char type :
Their values are unsigned integers that denote all the 65536 (216) characters in the 16-bit Unicode character set. This set includes letters, digits, and special characters.


The floating-point types:
Floating-point numbers conform to the IEEE 754-1985 binary floating-point standard.Since the size representation is a finite number of bits, certain floating-point numbers can only be represented as approximations


boolean data type
Boolean values are produced by all relational, conditional and boolean logical operators, and are primarily used to govern the flow of control during program execution.



The presence of primitive data types in java has been always a point which dictates it against complete object oriented programming language.
In support of complete object oriented programming ,java has a Wrapper class that resemble the primitive data type. ( I will post separately about Wrapper class) 

To understand these primitives type with working code, follow my post Code To understand primitive type in java

No comments:

Post a Comment