Why are nested comments forbidden in C++, Java inspite of the fact that nested comments are useful, neat, and elegant and can be used to comment out statements that have comments?
At least for C++ that's only partly true, there's no problem with:
/*
//
//
*/
However if you already got an /* comment in a section you want to comment out you might be able to do it by surrounding it with an #if 0
which I think many compilers optimize away. As in:
#if 0
/*
*/
#endif
C and C++ do it for ease of parsing. This way, when they hit a comment start of /*, the parser can trivially scan to the end. Otherwise, it would have to set up and maintain a stack, and then report errors if the comment tokens are unmatched.
As to why Java does it, the answer is simple - Java's syntax was designed to emulate C and C++, to trick people into thinking it was just as fast (in the beginning, Java was purely interpreted, so this trick WAS necessary to get traction). If nested comments were allowed, it might trip up some C programmers, and many angry blog posts would be written!