Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you comment out an entire class in Java?

Tags:

java

Not saying I would ever need this but how do you comment out an entire class after something like:

public class yadayada extends yadayadasquared {

    /**
     * Says Hello
     **/
    public String sayHello() {
        return "Hello";
    }
}

When there are nicely commented / documented methods within the class?

Let's imagine that it's for only for five minutes to avoid having the whole fork discussion....

And yes, you durned purists, I saw this!

https://stackoverflow.com/questions/123423/do-you-leave-historical-code-commented-out-in-classes-that-you-update

Let's assume this is for a 5 minute test. Repo work for that? Nope. Delete? Love the control-slash suggestion.

like image 314
John Stack Avatar asked Aug 14 '12 16:08

John Stack


2 Answers

Define "entire class".

Select the class's contents, hit Command+/*, and your IDE should single-line comment everything. This way you still have the class available, just without functionality. Or select the entire class. Or rename the file. Or... but ultimately, what's the point? Delete the file.

* Or whatever your IDE's sequence for single-line commenting is.

like image 149
Dave Newton Avatar answered Sep 28 '22 07:09

Dave Newton


if using an ide: one can do "ctrl + a", and then do "ctrl + shift + /", and that will comment out all of the code.

like image 34
nook Avatar answered Sep 28 '22 07:09

nook