Identifiers
public class Hello {
public static void main(String[] args)
{
System.out.println("Hello
Java!");
}
}
In Above Hello, main, args are called Identifiers
Rules for
defining Identifiers
·
Only Allowed characters are
§
a-z
§
A-Z
§
0-9
§
$
§
–
·
if we are using any other symbol we will get
Compile time error “IllegalCharacter”.
·
Identifier should not be starts with digit.
·
There is no length limit for java identifiers
but it is not recommended to take more than 15 length.
·
All Java class names, Interface names we can
uses as an Identifier, but it’s not recommended
public class Test {
int Runnable = 10;
int Integer = 20;
}
Keywords
Some identifiers are reserved to associate some
functionality or to represent values, such type of reserved identifiers are
called “ReservedWords” / “Keywords”
abstract
|
continue
|
for
|
new
|
switch
|
assert***
|
default
|
goto*
|
package
|
synchronized
|
boolean
|
do
|
if
|
private
|
this
|
break
|
double
|
implements
|
protected
|
throw
|
byte
|
else
|
import
|
public
|
throws
|
case
|
enum****
|
instanceof
|
return
|
transient
|
catch
|
extends
|
int
|
short
|
try
|
char
|
final
|
interface
|
static
|
void
|
class
|
finally
|
long
|
strictfp**
|
volatile
|
const*
|
float
|
native
|
super
|
while
|
*
|
not used
|
|
**
|
added in 1.2
|
|
***
|
added in 1.4
|
|
****
|
added in 5.0
|
Datatypes
Data Type
|
Default Value
|
Default size
|
boolean
|
false
|
1 bit
|
char
|
'\u0000'
|
2 byte
|
byte
|
0
|
1 byte
|
short
|
0
|
2 byte
|
int
|
0
|
4 byte
|
long
|
0L
|
8 byte
|
float
|
0.0f
|
4 byte
|
double
|
0.0d
|
8 byte
|
int : The size of
int is always fixed irrespective of platform hence the chance of failing java
program is very less if u r changing the platform hence the java is considered
as Robust

0 comments:
Post a Comment