简体   繁体   中英

How do I fix the checkstyle error “Expected an @return tag.”?

A segment of my code, when checkstyled, returns: "[ERROR] UserInfo.java:39: Expected an @return tag. [JavadocMethod]"

I'm just trying to add javadoc comments to my code and have never encountered this problem before. I don't know what to put in the javadoc comment to address the next part (that's why it's blank after "defines format of information")

 /**
 * Defines format of information.
 *
 * 
 *
 */
 public String toString()
 {
    String output = "Name: " + firstName + " "
       + lastName + "\n";
    output += "Location: " + location + "\n";
    output += "Age: " + age + "\n";
    output += "Status: ";
    if (status == OFFLINE)
    {
       output += "Offline";
    }
    else
    {
       output += "Online";
    }

    return output;
 }

最简单的方法是在javadoc注释中添加一个@return标记,该标记描述函数返回的内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM