RSS

Legal java identifiers?

10 Feb

Java identifiers can only contain letters, numbers, and underscores, and they must start with a letter or underscore. They cannot be Java keywords. 

So, take a look at your list: 

1. for – illegal; it’s a Java keyword. 
2. sum_of_data – legal. 
3. first-name – illegal; it has a – in it. 
4. ABC – legal. 
5. 42isThesolution – illegal; starts with a number. 
6. println – legal. 
7. B4 – legal. 
8. AnnualSalary – legal. 
9. “hello” – illegal; has a ” in it. 
10. _average – legal.

Advertisements
 
Leave a comment

Posted by on February 10, 2014 in Core Java

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: