Skip to main content

Java Identifiers



Language Fundamentals
Java Identifiers: A name in a java Program is called an Identifier, Which can be used for representing classes, methods, variables and labels.
Rules:
1.Java Identifier is composed of a sequence of characters, where each character may be a  ASCII Latin letters A–Z(\u0041–\u005a), and a–z (\u0061–\u007a) and for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024) and ASCII digits 0-9 (\u0030–\u0039).
i.e A-Z,a-z,_,$,0-9
The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.

If we use other character we will get compiled time error saying illegal character.
2. No identifier starts with the digit.
3. There is no length limit for java identifier, but SUN highly recommended up to 15 characters.
4. Identifiers in java are case sensitive.
5. We are not allowed to use reserved words (java keywords) as identifier.
6. All predefined java class names, you are allowed to use as identifiers.
Examples :

String JAVA;//Correct
String java;//Correct
String Java225; //Correct
String java1$;//Correct
String _java; //Correct
String        javal_examples;//Correct
String Runnable;//Correct and it is predefined interface name
String Seriliazable;//Correct and it is predefined interface name
String String ="Sekhar4j";//Correct and it is predefined java class String
System.out.println(String);//it prints Sekhar4j
String first-example;//Syntax error on token "first", = expected after this token
              //example cannot be resolved to a variable
String 225java2; //Syntax error on token "225", delete this token
String second1#;//   Syntax error on token "Invalid Character", delete this token

Comments

Popular posts from this blog

Yahoo! Calendar "Add Event" Seed URL Parameters

I can't seem to find any official documentation on this, so here are my notes. Some information gathered from  http://richmarr.wordpress.com/tag/calendar/ Other information gathered through trial and error, and close examination of the "Add Event" form on Yahoo!'s site. Yahoo! Calendar URL Parameters Parameter Required Example Value Notes v Required 60 Must be  60 . Possibly a version number? TITLE Required Event title Line feeds will appear in the confirmation screen, but will not be saved. May not contain HTML. ST Required 20090514T180000Z Event start time in UTC. Will be converted to the user's time zone. 20090514T180000 Event start time in user's local time 20090514 Event start time for an all day event. DUR value is ignored if this form is used. DUR 0200 Duration of the event. Format is HHMM, zero-padded. MM may range up to 99, and is converted into hours appropriately. HH values over 24 hours appear to be modulated by 24. Durations t...

Java Data Types

In java any variable has a type, any expression has   a type and every type is strictly defined. Compiler will check all assignments for type compatibility .Hence java is considered as strong typed language. Java Language is not considered as pure OOP language because some non-objects (primitive data types) we have to maintain in our code .So sun people has introduced wrapper class to convert primitive to object form. DATA TYPE SIZE RANGE WRAPPER CLASS Default value byte 1byte -128 to +127 Byte 0 short 2 bytes -32768 to +32767 Short 0 int 4 bytes -2147483648 to +2147483647( Integer 0 long 8 bytes -2 pow 63 to 9223372036854775808L Long 0 float 4 bytes -3.4e38 to + 3.4e38 Float 0.0 double 8 bytes ...