File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes //Comment in java 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 in java" Watch "//Comment in java" New topic
Author

//Comment in java

Shweta R Dhaneshwar
Ranch Hand

Joined: May 27, 2005
Posts: 35
D:\Java\EditPlus 2>javac Test.java
Test.java:10: unclosed character literal
}
^
Test.java:10: ';' expected
}
^
2 errors

why this error?


Shweta Dhaneshwar.<br />SCJP 1.4 90%
swapnil paranjape
Ranch Hand

Joined: May 15, 2005
Posts: 126
hi this is the solution for the error problem.i guess u can now understand y error was comming.

class Test
{
public static void main (String[] args)
{
//char a=''\'u000A';
}
}

swapnil.
Shweta R Dhaneshwar
Ranch Hand

Joined: May 27, 2005
Posts: 35
Hi Swapnil,
Can you explain this in detail?
Soni Prasad
Ranch Hand

Joined: Mar 09, 2005
Posts: 97
Problem is because of \u000A
in //char a='\u000A';
where \u000A is \n and this line is treated as

//char a='
';

soni.


SCJP 1.4, SCBCD 1.3
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
See if this helps:
http://qa.jtiger.org/GetQAndA.action?qids=5


Tony Morris
Java Q&A (FAQ, Trivia)
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Originally posted by Soni Prasad:
Problem is because of \u000A
in //char a='\u000A';
where \u000A is \n and this line is treated as

//char a='
';

soni.


in tony morris website its written

The compiler will fail because of the Unicode escape in what appears to be (but is not) a single line comment. The Unicode escape \u000A is lexically translated before compile-time into a Line Feed character, therefore, the next line, `; will cause the compiler to fail.

but i have heard that anything behind // will be completely ignored
but this is bit strange

but i think this will not true in /* */ type of comments

according to tony...
he say unicode is translated before complile time...
what this ?? howz that posible...as java compiler will know everything about code when compling..howz before that

pls explain...and what do u mean by lexically trnaslated ???


Thanks and Regards, Amit Taneja
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
amit,
On that same web page there is a reference to the Java Language Specification that explains lexical translation of Unicode Escapes (which occurs prior to compilation). See if that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: //Comment in java