aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is wrong with these two codes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is wrong with these two codes?" Watch "what is wrong with these two codes?" New topic
Author

what is wrong with these two codes?

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531



i cant even seem to understand the errors...first one is illegal line end and second is unclosed literal? what does these mean?
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

hint: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4635699


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
can you explain this to me in simple language
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

The unicode '\u000A' converted into new line character before class AQuestion1 get compiled, it will show to compile something like


try the following code:


Hope its clear to you, let me know if you need further clarification?
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
you mean everything after \ is being omitted? there is something in the jls about \ being followed by u.....am not clear still
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Because this unicode literal represents new line '\n' and java forbids using it.


SCJP 1.6 96%
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
understood now.....

\u000a means \n...newline

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
and \u are evealuted before the class compiles
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


this is the correct usage....
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

But then you don't have the char


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
It compiles and run successfully on my computer but with no output.

you can also read this
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

There IS output. The char. But the char is a enter so I guess you mist it.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
I could not understand, what you trying to say.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Oke try this:



When you run it, you can see that a new line is printed. That is the char.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
got it...so yes we dont have '\012' character as it is octal version of enter.

thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: what is wrong with these two codes?