File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Comment...?" Watch "Comment...?" New topic


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

Joined: Mar 22, 2000
Posts: 13027
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.
I agree. Here's the link:
subject: Comment...?
It's not a secret anymore!