Monday, February 15, 2010

Identifiers & JavaBeans

Welcome back my friend...as you visit this posting, we can assume that you've had quite seriousness in preparing for SCJP. Let's keep up our pace of working for SCJP so that high score is a very feasible dream.

Let's start with Java identifiers convention
a) Legal identifiers means that your code is syntatically legal.
b) Sun's Java Code Convention: It's the recommended naming mechanism by Sun Microsystem for more standardized naming system for all Java programmers
c) JavaBeans Naming Standards is not listed on the exam but you will need them in real-life programming.

Legal Identifiers

To have legal names in Java programming, you need to know some rules for creating legal identifiers
a) identifier must start with a letter, a currency sign, and connecting character (such as underscore). Identifiers must not start with a number.
b) the second character then can contain any combination of letters, currency characters, connecting characters, or numbers
c) there's no limit for characters' length
d) no keyword should be used (click here for Java keyword)
e) in Java, identifiers are case-sensitive; "animal" dan "Animal" are 2 different identifiers in Java.

examples of legal names are:
int $currency12;
long ___4_;
short i_love_this_crazy_long_identifier_name;


examples for illegal names are:
int -wrong-number;
short 9milk;
double sharp#;