We can use small letter, Capital letter along with two special char _ and $ for creating identifier in java. We can not use numbers before character.
Some sample correct and incorrect identifiers are given for reference :
The special characters $ and _ can be used as first character in identifier of java.
class Test { public static void main(String args[]) { int test_1=0; //correct int Test123 =0; //correct int test123$ =0; //correct int test123_$ =0; //correct int 123test = 0; //incorrect int test123% =0; //incorrect } }
Please note as naming convention rule that all variable name should start with small letter. If we want to use two words to create identifier then we can combine both letters with _ or $ or we can make first char capital of next word.
0 comments:
Post a Comment