Well, as title says it is a weird question. I want to create an int called int and of course if i write;
int int;
java(eclipse) gives error. So I've been wondering if it is possible to create such a thing? if you are asking me why i insist on this, I've created str for strength, agi for agility, but int for intelligence can not be created. So should I just describe it in another way or is there a simple way to do it?
You can't. int
isn't a valid identifier in Java, because it's a keyword.
From JLS 3.8:
An identifier cannot have the same spelling (Unicode character sequence) as a keyword (§3.9), boolean literal (§3.10.3), or the null literal (§3.10.7), or a compile-time error occurs.
Compare this with str
, which isn't a keyword. (And neither is String
, in fact.)
As Greg says, it's clearer to use full names (strength
, intelligence
etc) anyway.
See more on this question at Stackoverflow