• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

//Comment in java

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swapnil,
Can you explain this in detail?
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this helps:
http://qa.jtiger.org/GetQAndA.action?qids=5
 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
And inside of my fortune cookie was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic