Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java comment for getter and setter method

Tags:

java

comments

my question is should i comment like following:

/**
     * Getter for {@link #auto_key}
     * @return {@link #auto_key}
     */
    public String getAuto_key() {
        return auto_key;
    }
    /**
     * Setter for {@link #auto_key}
     * @param auto_key the {@link #auto_key} to set
     */
    public void setAuto_key(String auto_key) {
        this.auto_key = auto_key;
    }

basically i want to ask, using {@link} in comment for getter and setter method is correct? or should i use normal comment without using {@link} ? and this way is a java standard or not ?

like image 631
pd27 Avatar asked Dec 27 '22 03:12

pd27


1 Answers

Actually, I deliberately don't javadoc getters and setters, because you aren't adding any value by doing so - they are what they are... accessor methods. In fact, you would be creating a kind of code bloat by adding javadoc to them.

I only put javadoc on non-getter/setters.

like image 64
Bohemian Avatar answered Jan 08 '23 17:01

Bohemian