Download Core Java Book by NB PDF

TitleCore Java Book by NB
TagsJava Programming Language Method (Computer Programming) Data Type Reserved Word Array Data Type
File Size5.7 MB
Total Pages459
Document Text Contents
Page 2

Core java NAGOOR BABU

2

DURGA SOFT

Example:

class Test{

int number=10;

int Number=20;

int NUMBER=20; we can differentiate with case.

int NuMbEr=30;

}

Rule 5: There is no length limit for java identifiers but it is not recommended to take more than

15 lengths.

Rule 6: We can’t use reserved words as identifiers.

Example: int if=10; --------------invalid

Rule 7: All predefined java class names and interface names we use as identifiers.

Example 1:

class Test

{

public static void main(String[] args){

int String=10;

System.out.println(String);

}}

Output:

10

Example 2:

class Test

{

public static void main(String[] args){

int Runnable=10;

System.out.println(Runnable);

}}

Output:

10

Even though it is legal to use class names and interface names as identifiers but it is not a good

programming practice.

Which of the following are valid java identifiers?

Similer Documents