<p>This question would probably apply equally as well to other languages with C-like multi-line comments. Here's the problem I'm encountering. I'm working with Java code in Eclipse, and I wanted to comment out a block of code. However, there is a string that contains the character sequence "*/", and Eclipse thinks that the comment should end there, even though it is inside a string. It gives me tons of errors and fails to build.</p>

<pre><code>/*
   ... some Java code ...
   ... "... */ ..." ...
   ... more Java code ...
*/
</code></pre>

<p>Does the Java specification match with Eclipse's interpretation of my multi-line comment? I would like to think that Java and/or Eclipse would account for this sort of thing.</p>

[{'answer_id': 32916, 'author': 'Damien B', 'author_id': 3069, 'author_profile': 'https://Stackoverflow.com/users/3069', 'pm_score': 4, 'selected': True, 'text': '<p>Eclipse is correct. There is no interpretation context inside a comment (no escaping, etc). See <a href="http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48125" rel="noreferrer">JLS §3.7</a>.</p>\n'}, {'answer_id': 32918, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>Yes, I am commenting the code out just to do a quick test. I've already tested what I needed to by commenting the code out another way; I was just curious about what appears to be an odd misfeature of Java and/or Eclipse.</p>\n"}, {'answer_id': 32927, 'author': 'joev', 'author_id': 3449, 'author_profile': 'https://Stackoverflow.com/users/3449', 'pm_score': 0, 'selected': False, 'text': '<p>A simple test shows Eclipse is correct:</p>\n\n<pre><code>public class Test {\n  public static final void main(String[] args) throws Exception {\n    String s = "This is the original string.";\n    /* This is commented out.\n    s = "This is the end of a comment: */ ";\n    */\n    System.out.println(s);\n  }\n}\n</code></pre>\n\n<p>This fails to compile with:</p>\n\n<pre><code>Test.java:5: unclosed string literal\n    s = "This is the end of a comment: */ ";\n</code></pre>\n'}, {'answer_id': 32931, 'author': 'axk', 'author_id': 578, 'author_profile': 'https://Stackoverflow.com/users/578', 'pm_score': 0, 'selected': False, 'text': '<p>I may be helpful to just do a "batch" multiline comment so that it comments each line with "//". It is Ctrl+"/" in Idea for commenting and uncommenting the selected lines, Eclipse should have a similar feature.</p>\n'}, {'answer_id': 32982, 'author': 'Cem Catikkas', 'author_id': 3087, 'author_profile': 'https://Stackoverflow.com/users/3087', 'pm_score': 2, 'selected': False, 'text': '<p>In Eclipse you can highlight the part of the source code you want to comment out and use the Ctrl+/ to single-line comment every line in the highlighted section - puts a "//" at the beginning of the lines.</p>\n\n<p>Or if you really want to block-comment the selection use the Ctrl+Shift+/ combination. It will detect the block comments in your selection. However undoing this is harder than single-line comments.</p>\n'}, {'answer_id': 143915, 'author': 'davenpcj', 'author_id': 4777, 'author_profile': 'https://Stackoverflow.com/users/4777', 'pm_score': 0, 'selected': False, 'text': "<p>I often use only <code>//</code> for inline commments, and use <code>/* */</code> only for commenting out large blocks the way you have.</p>\n\n<p>A lot of developers will still use /*  */ for inline comments, because that's what they're familiar with, but they all run into problems like this one, in C it didn't matter as much because you could #if 0 the stuff away.</p>\n"}]
['https://Stackoverflow.com/questions/32897', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']