Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strange problem in comments.

 
sony ali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi: i mfacing a strange problem in comments. ie
i have a code
public class ali{

//char a='\u00A'
}
problem: whan i m compiling this code, the code s not compiling. i donot know why the compiler s reading single line coments?

second thing:
see this code
public class ali{
//int a= 2;
//byte b= 2;
//float f= 2;
//double d=2;
//in all other cases compiling
}
problem 2: when i mcompiling this code , it compile successfully.
plz explain the difference of these two problems.
thxs
bybyby
love to all
 
Hima Mangal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sony,
i think this is because the escape sequence '\u000A' stands for a special character, that is the carriage return character so that ur code
char c='\u000A'; is equivalent to
char c=
;
that is, the compiler performs the unicode conversion while compiling and results in compiler error.
pls correct me if i am wrong.
------------------
Hima
 
Naveed Hassan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
but why the compiler is not ignoring the rest of the line by finding comment symbol==> // on the start of the line
BYe
 
sony ali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi : hina mangal
actully my question s that as we know that "when a line having single line comments . it s not read by the compiler". so why here the compiler is reading this (//char a= \u000A)explain me.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3711
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason is such unicode escape sequences are converted to appropriate characters in "pre" compilation step. It's true that the compiler won't look at anything after // in that line, but //char a='\u00A' is converted to:
//char a='
'
even before the compiler starts working on it.
HTH,
Paul.

------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

[This message has been edited by Paul Anil (edited March 26, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic