Java Language:
==============
If you are writing any java program in that Program Any(keyword , Spcl Symbol, User defined Words, Properties Name, Operation name).
1.Character Set.
2.Data Types.
3.Userdifined Words or Identifiers
4.KeyWords
5.Var.(**Final Var (Kind of Constant in Java))
6.Literals
7.Operators
8.Control Stmnts
9.Array
==========================================================
1.Character Set.:
================
1. 0 to 9 (Numeric)
2. (a to z) and (A to Z)
3. All the Spcl Symbol Aval. on Keyboard.
**
1.C language is on the basis of ASCII char-set(8-Bit).
128 64 32 16 8 4 2 1
MAx. bit Rep.====256 (256 char. set itself)
C language supports only english Language.
2.Java Follows 16 bit unicode Char-Set.
Java Supports I18N and Localization.
just by using its locale Code Java can Support Cor.poding.
language.
Note:
====
1. C supports 8 bit ASCII Char- set
2. java Supports 16- Bit Unicode Char-Set.
=========================================================
Data Types in Java
===================
Two Types Of Datatypes :
1.Primitive Datatypes
2.User Defined Datatypes
1.
Datatypes Default Value Size Range
byte 0 1 -128 to +127
short 0 2
int 0 4
long 0 8
float 0.0f 4
double 0.0 8
boolean false --
char blank Space --
byte b1;(Some Condition for Assigning the Default Value. to Var.)
SOP(b1);------0
2. User Defined Data Types:
===========================
1.class
2.interface
From Jdk1.5
1. enum
2. Annotation(Very Imp.)
======================================================
4.KeyWords::- Keywords are having some predefine meaning which cannot be changed. In your further programme keywords cannot be used as identifiers or user defined words.
List Of Keywords:
================
abstract Assert Boolean break throw byte
case transient catch char class const
continue default instanceof do double else
enum extends final finally float for
goto If implements import int interface
long Native new package while private public
short Static strictfp super switch synchronized
this protected try void volatile return
=========================================================================================
3.Userdifined Words or Identifiers in Java :
===========================================
class HelloSri{
int a=10;
void show(){
// it will Display all the details..
}
}
1. HelloSri name of class
2. a name_of_var_of_type_int_4bytes_of Memory
3. show method name.
=====================================
Boy kiran , Ram,Siva
Girl komal, Mohan
Animal bob name of the Dog
Place_name Delhi (City Name)
===================================================================================
class HelloSri{
1. var
2. Method
}
Class_name:
===========
class name Should Start With Cap.
class HelloSri{
}
class HelloWorld{
var
====
int a=10;
int ab=20;
Method or Function(C,C++)
===========================
void show(){
}
void showDetails(){
}
}
class Keyword [class_name]{
}
1. keyword i.e class (Keyword)
2. class_name i.e HelloSri (name of the Class is HelloSri).
***
class for(Keyword){ // Not Allowed.
}
Rules to define the Identifiers in java :
================================
1. Keywords cannot be used as identifiers.
2. Identifier must not start with any numeric or it is always recommendable to starts some of the identifiers with small case.(Var.)
3. It must not contain any special symbol other than ( _ or $).
4. Identifier must not contain any blank space in between.
5. Identifiers may contain numeric but it should not be in starting.
(OCPJP)
Based on Above Rules:
======================
class Hello{
int a;
int ab;
int ab1;
//int 1ab; - not ok
int a1b;
int a_b;
int ab_;
int _ab;
int a$b;
int _;
int _$;
//int ab*; - not ok
//int ()_; - not ok
//int for; - not ok keyword
//int true; - not ok boolean Lit.
int Integer; not the Keyword.
int INT;//ok
int For;//ok
int sate Code;//not allowed
int sateCode;//ok
}
=========================================================================================
1. When we are writing int Integer, then it is being considered as variable of type int. This “Integer” will not be considered as keyword.
2. When you are writing java.lang.Integer then in this case it is invalid declaration because special symbols are not allowed in identifiers name.
3. In java corresponding to the primitive data type wrapper classes has been designed which is available in java.lang package. Therefore “Integer int” here Integer will be considered as wrapper class and ‘int’ will be considered as a reference variable of type Integer.
class abc{
}
class Abc{
}
~-~~-~~~-~~-~
Please watch: "Object Class Methods in java With Examples "
• Object Class Methods in java With Ex...
~-~~-~~~-~~-~