This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Comment...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Comment...?" Watch "Comment...?" New topic
Author

Comment...?

Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
Why doesn't the following compile?
public class AQuestion
{
public static void main(String args[])
{
//char a = '\u000A';
}
}
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
The Java compiler can't tell the difference between the '\u000A' in your program and an actual end of line in your code. It sees your source program as:


Instead, use '\n'
[ November 30, 2004: Message edited by: Mike Gershman ]

Mike Gershman
SCJP 1.4, SCWCD in process
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
What Mike meant to type was:




Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
The reason for this is that Unicode characters get translated on the fly as the source code file is being read and before the compiler sees them.
Bill
 
wood burning stoves
 
subject: Comment...?
 
Similar Threads
JSP Element mixture
WA #1.....word association
Excluding methods from a test case
No ClassDefFoundError
simple doubts, please explain.