• 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

nested comments

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought nested comments aren't allowed. this compiles and prints "The End"

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Get me the mayor's office! I need to tell him about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic