Reputation: 3652
Let see this example in Java,
public void methodY(){
/* some explain ...... */
int x=1;
}
Ok, now I want to comment the whole methodY so I put methodY inside /*
*/
like this:
/*
public void methodY(){
/* inside comment ...... */
int x=1;
}
*/
However, the inside comment /* inside comment ...... */ prevent that to be happen.
In Java, do we have a way to comment the whole block of code that already containing /* comments?
Upvotes: 4
Views: 9473
Reputation: 3509
ON eclipse select the block you want to comment and use:
ctrl+shift+/
Upvotes: 1
Reputation: 45060
Just select the block of text(already containing comments) you want to comment and press Ctrl+Shift+/. But this might override the comments already present, which needs to be taken care of.
Instead you can try inline comments, by either providing //
at the beginning of each line or using the Ctrl+/ key combination and press it again to undo it. But you need to know that if you comment each line using the inline comment, then you can avoid that scenario, but it would make your job of commenting a bit tedious if the block to be commented has a lot of lines.
The call to use either of the commenting styles is upto you and the needs.
Note: This works for Eclipse running on Windows.
Upvotes: 1
Reputation: 35
For Eclipse IDE : you can use
ctrl+shift+c (to comment and uncomment both)
or you can use ctrl+shift+/ (to comment) and ctrl+shift+\ (to uncomment)
Upvotes: 1
Reputation: 115328
Comment this using inline comment //
.
Typically IDEs support Ctrl-/ on selected block.
Upvotes: 7
Reputation: 69259
For example in Netbeans you can select all lines and press Ctrl/, this will comment in whole section (not sure if it recomments the /* ... */
again) in //
style.
I think there are similar options available in other IDE's.
I am not aware of Java itself processing 'double' comment blocks.
Upvotes: 1