aspose file tools*
The moose likes Beginning Java and the fly likes valid identifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "valid identifier" Watch "valid identifier" New topic
Author

valid identifier

pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
newState


is this a valid identifier? because it contains new
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

it is. but if you leave space between new State then it is not.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

It is valid. myClass is valid, myStaticBoots is valid, myAbstractDog is valid. newYork is also valid As long as the given name is not a reserved keyword.


[My Blog]
All roads lead to JavaRanch
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Why don't you write a small program with a variable named "newState", try to compile it and see what the compiler says?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
you mean to say that newState is valid because it is not a keyword, even if new is keyword and it is part of identifier?

and one more thing guys, how do you identify whether ti use lowercase or uppercase letters when declaring variables?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Names are usually consisting of word, whose first letter is upper-case.
Like "isRainFalling", "carColour", "dayOfMonth"....
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
is carcolor and Carcolor valid?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36513
    
  16
Both "Carcolor" and "carcolor" will get past the compiler as valid identifiers, but (as you already know) they don't match the coding conventions for people who have to read the code.
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
you mean to say it is a set standard?

not a strict rule or error?


thank you so much.


i am learning so much from here
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You can check some common naming conventions here :
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#367

Note that this is mandatory, but it really helps to make your code clean and readable to others.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: valid identifier
 
Similar Threads
What are valid characters to use in an identifier?
Binary AND Operator
enums
SCJP beginers question
label(s) question