Declaring Fields:
Formatting Identifiers
In the Java programming language, an identifier is a name given to a variable, class, or method. Identifiers start with a letter, underscore (_), or dollar sign ($) and valid currency symbols. Subsequent characters can be digits. Identifiers are case-sensitive and have no maximum length.The following are valid identifiers:
1. identifier
2. userName
3. user_name
4. _sys_var1
5. $change // Legal but not encouraged
Initializing Fields
This section addresses the initial values allocated to the fields (attributes)of a newly created object.
string a="name";
Java technology provides the following mechanisms for field initialization.
● Initialize using default values
● Initialize using explicit values
● Initialize using constructors
Java Language Keywords
Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords
Source : http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html const
and goto
are reserved, even though they are not currently used. true
,false
, and null
might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.abstract | continue | for | new | switch |
assert *** | default | goto * | package | synchronized |
boolean | do | if | private | this |
break | double | implements | protected | throw |
byte | else | import | public | throws |
case | enum **** | instanceof | return | transient |
catch | extends | int | short | try |
char | final | interface | static | void |
class | finally | long | strictfp ** | volatile |
const * | float | native | super | while |
* | not used | |
** | added in 1.2 | |
*** | added in 1.4 | |
**** | added in 5.0 |