• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested comments

 
Alex Sbityakov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought nested comments aren't allowed. this compiles and prints "The End"

 
Bill Tripper
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on your code, nested comments are not allowed. If they were, your code would not compile. I'm not sure what your really asking.
Your first comment runs from the first "/*" to the first "*/". The second "/*" (followed by jkktj) is ignored, since nested comments are not allowed and it's embedded within a comment. The second comment runs from the third "/*" to the second "*/".
 
Alex Sbityakov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems the nesting of /*..*/ style comments are not allowed, precisely for the reason that the starting tag of the second set of comments is ignored by the compiler. However, the nesting of // and /*..*/ style comments are OK.
 
John McErkland
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alex Sbityakov:
It seems the nesting of /*..*/ style comments are not allowed, precisely for the reason that the starting tag of the second set of comments is ignored by the compiler. However, the nesting of // and /*..*/ style comments are OK.

In your code the first comment starts with /* and doesn't end until jkktj*/. The whole first comment is
/* comment
if (true) {
temp1 temp = new temp1();
System.out.println("Done");
}
/*jkktj*/
then there is a second comment /*comment*/.
So compiler sees no problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic