Wednesday, 23 March 2011

3.9 Keywords

Keywords are predefined identifiers (name of basic programming elements) which are having a special meaning in java source code.

Rule

Keywords can’t be used as user defined identifiers, means, can’t be used by the programmer for variable, method, class names because keywords are reserved words.

There are 50 keywords are available in java, among them 47 are introduced in java1.0 and 1.1

In java1.2 new keyword strictfp was added

In java1.4 new keyword assert was added

In java1.5 new keyword enum was added

The following character sequences, formed from ASCII letters, are reserved for

use as keywords and cannot be used as identifiers (§3.8):

The keywords const and goto are reserved, even though they are not currently

used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.

While true and false might appear to be keywords, they are technically

Boolean literals (§3.10.3). Similarly,

while null might appear to be a keyword, it is technically the null literal

Note

Below three are Literals not key words

Boolean Literals true , false

Object Literal (default value) null

Note

Keywords should write in lower case. Violation leads to compile time error.

The below are the list of java keywords

Java files

class

interface

enum(1.5)

data types

byte , short, Int ,long

float, double ,char

boolean, void

Memory location

static

new

Control statements(11)

Conditional(5)

Loop(3)

Transfer(3)

If , else

switch, case, default

while, do

for(; ;)

for(:) (1.5)

break, continue, return

Access specifier(3)

Private, , protected, public

Access modifiers

static

final

abstract

native

transient

volatile

synchronized

strictfp

Inheritance relationships

extends

implements

Object relationships

this

super

instanceof

package

Package

Import

Exceptional handling

try, catch, finally

throw, throws

assert

Reserved keywords

goto

const

No comments:

Post a Comment