Variable is just like container that holds some content or value in it. It has its own rage or size and type.
________________________________________________________________________________
Constants:- as the name sought these are fixed values which can never be change.
Example:
final int MAX_AGE=29;
“final” keyword is used to declare a constant in java.
________________________________________________________________________________
keywords:- Keywords are reserved words which has some special meaning for the compiler. they can not be used as identifiers. if so, compiler will show error.
Example
if, goto, while, for etc.
Complete list of java keywords
________________________________________________________________________________
data types can be categorized into two category and so variable.
Primitive Type – Primitives are like the cups at the Coffee-House They come in different sizes and each has name like small , big, medium. Java primitives come in different sizes and name. You must declare a variable with a specific type.
Example
byte x=10; // Take 1 byte in memory
short y=500; // Take 2 bytes in memory
int a=40000; // Take 4 bytes in memory
Primitive Data Types List
In Java, primitives come in different sizes with different names. When you declare a variable in Java, you must declare with a specific type.
Reference type
A Reference variable holds bits that represents a way to access an object. It doesn’t hold the object itself, but it holds something like reference address to the object. Reference type does not have size or bit depth.
_______________________________________________________________________________
Class and Interfaces – The First letter should be capital, and first letter of the inner words should be Capital.
Example : Account
PrintWriter
Emp
Runnable
Methods – The First Letter should be lowercase, and then normal camelCase rules should be used. Name should be noun-verb pairs.
Example
getBalance
setCustomerName
Variables – Same rule as Method Rule.
Example
buttonWidth
myString
Constants – All in Uppercase.
Example
MIN_HEIGHT
________________________________________________________________________________
Identifier is a name given to a class, variable, constant or method.
Rules for Declaring a Legal Identifier:
Example of legal identifiers
int _a;
int $count;
int ____ag_e;
int _$;
int detaild_name_for_identifier;
Example of illegal identifiers
int :a;
int -count;
int age#;
int .first;
int 3s;