Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Comment line "//"

 
Prakash Rai
Ranch Hand
Posts: 106
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Q1. If I have commented then also why it is giving error.If have commneted then it is supposed not to read by compiler So their is no question What I have written?
Q1.If I have enclosed within double quote("") It should consider as String?


Please Help me as soon as possible.....
Thanks in advance...
 
fred rosenberger
lowercase baba
Bartender
Posts: 12149
31
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get no compiler error when I try your code.

What is the exact text of the error you are getting?
 
Prakash Rai
Ranch Hand
Posts: 106
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:I get no compiler error when I try your code.

What is the exact text of the error you are getting?

Error:
Multiple markers at this line
- String literal is not properly closed by a
double-quote
- Invalid unicode
 
Prakash Rai
Ranch Hand
Posts: 106
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:I get no compiler error when I try your code.

What is the exact text of the error you are getting?

Error:
Multiple markers at this line
- String literal is not properly closed by a
double-quote
- Invalid unicode
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I even tried it from the cmd prompt and got below error.
Test.java:7: illegal unicode escape
// String str="c:\program\user"; Error Invalid unicode "
^
1 error
 
Prakash Rai
Ranch Hand
Posts: 106
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Jai wrote:I even tried it from the cmd prompt and got below error.
Test.java:7: illegal unicode escape
// String str="c:\program\user"; Error Invalid unicode "
^
1 error
yeah correct but after commenting also it is giving error why ?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12149
31
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mistake...i was not compiling what i thought i was.

my guess is that this is due to the unicode conversion that happens before much else. Even though it is a comment, something is trying to make it unicode, so the "\u" is being read as a unicode reference.

If you change the comment line to something like

// String str="c:\program\puser"; Error Invalid unicode

it compiles.
 
Prakash Rai
Ranch Hand
Posts: 106
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks fred rosenberger.. I too understand same concept...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic