Sunday, February 17, 2013

5.Declaring Fields

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 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.
abstractcontinuefornewswitch
assert***defaultgoto*packagesynchronized
booleandoifprivatethis
breakdoubleimplementsprotectedthrow
byteelseimportpublicthrows
caseenum****instanceofreturntransient
catchextendsintshorttry
charfinalinterfacestaticvoid
classfinallylongstrictfp**volatile
const*floatnativesuperwhile
* not used
** added in 1.2
*** added in 1.4
**** added in 5.0
 Source : http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html 

 

2 comments:

  1. I like the helpful info you provide in your articles.
    I'll bookmark your weblog and check again here regularly. I am quite sure I'll learn many new stuff right here!
    Best of luck for the next!

    Feel free to visit my web page ... garbage disposer

    ReplyDelete