Originally posted by William Wild:
So basically any [A-Z][a-z,A-Z,_]* is ok.
But is the '_' ok at the start?
I would test but haven't got access to a Java Compiler at the mo.
Cheers
Bill
AFAIK, '_' isn't a letter, so according to Lionel's explanation above, you cannot start any identifier name with it. Also, your regex does describe SOME possible indentifier names, but other characters are allowed as well. In particular, I was surprised when I learned that '$' is valid in a name. (For some reason I think it is allowed at the beginning, too, but check the link Lionel gave to check.) It also makes sense that Java allows other Unicode characters as well. This allows programmers that don't speak English as their native language to use names from their own language, including those that have characters not available in the English alphabet. So I think
you should read the link above. It says the rules are for variable names, but it still applies to classes and methods as well.
Layne