Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SCJP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i read that we cannot use keywords as identifiers.
but there was no prblem either with compiling or running the following program which is as follows
public class Literal{
public static void main(String args[]){
int assert=150;
System.out.println(assert);
}
}

the same is the case with String. can somebody plz clarify . also plz letme know if there are some other keywords that can b used as identifiers.
thank u
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
assert is a key word ONLY as of version 1.4; By default, javac program name uses the 1.3 version of the compiler, and lets you use assert as an identifier. For the compiler to be 'assertion aware', you need to use the explicit syntax javac -source 1.4 program name Since you didn't do that, the compiler doesn't complain...!!!
Hope that helps...!!!
( Just read Kathy and Bates' explanation of it in the book, so hope that is very very very accurate... )
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
String is not a keyword.It is class name.So String can be used as identifier.
Regards
Jaya S K
 
It's a tiny ad. At least, that's what she said.
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic