aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why a legal identifier cannot include the character # Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why a legal identifier cannot include the character #" Watch "Why a legal identifier cannot include the character #" New topic
Author

Why a legal identifier cannot include the character #

Krishnamoorthy Sethuraman
Greenhorn

Joined: Dec 12, 2005
Posts: 24
Why is the identifier e# not a legal identifier for java compiler? The rules for valid identifier given in K&B book are:
----------------------------------------------------------
1. Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). Identifiers cannot start with a number!
2. After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
3. In practice, there is no limit to the number of characters an identifier can contain.
4. You can't use a Java keyword as an identifier. Table 1-1 lists all of the Java keywords including one new one for 5.0, enum.
5. Identifiers in Java are case-sensitive; foo and FOO are two different identifiers.
----------------------------------------------------------
Accordingly the identifer e# doesn't come in any of the above 5 category.
So, why is it not a legal identifier?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

I guess they forgot to add that any special characters other than the currency symbols are not allowed.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Kino Lobo
Greenhorn

Joined: Feb 08, 2006
Posts: 20
Hi folk!

1. Identifiers must start with a letter...


The # is not a letter!
By letter we should consider A to z, I guess...

PS.: I'm studying by Head First too...


I'd rather trust a man who works with his hands!
Valentin Jacquemin
Ranch Hand

Joined: Feb 15, 2006
Posts: 35

2. After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.


In this list there isn't the '#' character...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why a legal identifier cannot include the character #