Tutorials for Java ,Core java ,Advance java ,oracle ,HTML, CSS, JavaScript, Java and other programming language tutorial Learn Java tutorial for beginners with examples in eclipse online. Java tutorial point for core java, servlet, jsp, struts, spring, for learning web technologies online. Content includes tutorials and references relating to HTML, CSS, JavaScript, PHP, AngularJS, SQL, Bootstrap, Node.js, and jQuery this is a website like w3school tutorialspoint etc

Search This Blog

About

Header Ads

Wednesday, 21 March 2018

JAVA IDENTIFIERS

0 comments

JAVA IDENTIFIERS

A name in java program is called identifier which can be used for identification purpose it can be method name,variable name,class name,level name .

class test
{
public static void main(String[]args)
{
int x=10;
}
}

1-class -class name
2-main-name method
3-string-predefined class
4-args-Array
5-x-variable 

Rules For Defining java Identifiers-

The only allowed character in java given below-

Rule-1

a to z

A to Z

0 TO 9

$

-

EXAMPLE-

total-number (right)

total # (Wrong)

Rule-2
 
identifiers can't starts with the digit

Example-

total123 (right)

123total (Wrong)

Rule-3

Java identifiers are case sensitive of course java language it self is treated  case sensitive programming language .

Example-

class test{
int number=10;
int Number=20;
int NUMBER=30;
}

Rule-4

There is no length limit for java identifiers but it is not recommended to take too lengthy identifiers .

Rule-5

We cant use reserved word about as identifiers

Example-

int x=10;  (right)
int if=120; (wrong)

All Predefined java class name or , interface name we can use as identifiers .even though it is valid but it is not a good  programming practice because it reduce readability and creates confusion .

Which have the following are valid java identifiers

total_nuimber  (right)

total#  (wrong)

123total (wrong)

ca$h (right)

-$-$-$-$-$ (right)

all@hands (wrong)







No comments:

Post a Comment