File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

//Comment in java

 
Shweta R Dhaneshwar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D:\Java\EditPlus 2>javac Test.java
Test.java:10: unclosed character literal
}
^
Test.java:10: ';' expected
}
^
2 errors

why this error?
 
swapnil paranjape
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swapnil,
Can you explain this in detail?
 
Soni Prasad
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem is because of \u000A
in //char a='\u000A';
where \u000A is \n and this line is treated as

//char a='
';

soni.
 
Tony Morris
Ranch Hand
Posts: 1608
 
amit taneja
Ranch Hand
Posts: 813
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ???
 
Tony Morris
Ranch Hand
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic