aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Literal Line feed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Literal Line feed" Watch "Literal Line feed" New topic
Author

Literal Line feed

Pal Sudarshan
Ranch Hand

Joined: Jun 10, 2004
Posts: 52
Hi,

When I compile the code below, I get an error message stating, "illegal line end in character literal" What is reason for that? When and how can we use this literal then?

Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127
Originally posted by Pal Sudarshan:
Hi,

When I compile the code below, I get an error message stating, "illegal line end in character literal" What is reason for that? When and how can we use this literal then?



During the compilation process, the unicode character \u000A gets converted to the end of line character which causes the compiler error. You can use '\n' for newline instead.
Pal Sudarshan
Ranch Hand

Joined: Jun 10, 2004
Posts: 52
First, thank you for the reply.

Why does it cause compiler error? "It gets converted to end of line." If it gets end of line, what is the problem with that? Why doesn't it do the same function as '\n'? If it is in the language, then where can we use the literal?

Again, thanks for the reply.
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
The problem with that code is the compiler converts unicode characters before it parses the code. Therefore, the java compiler will end up seeing a line that looks like:

char c = '
';

which is illegal. I don't know the exact sequence the compiler goes through, but I suppose you could use unicode sequences to build up keywords and that would also work.

In any case, the compiler does not convert '\n' before parsing the code, so use that instead of '\u000A'.

Robert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Literal Line feed