java Zen - Notes

First, the code comments

1. What is a comment?

The so-called notes, not a bunch of crap. But to explain to one of your program clear and concise. For example, comments can be used to describe the information you write the class, describing the role of this class of a method, meaning the method parameters, and return values ​​and other information

2. What types of comments have?

There are three kinds of comments: single-line comments: // footnotes multi-line comments: / * comment * Content / Document Notes: / ** footnotes * /

public class Demo{
    // 这是单行注释
    String str="Hello World!";
    /*
       这是多行注释
    */
    String str1="多行注释";
    /**********文档注释如下:**********************/
    /**
     * @param session      :
     * @param productId    :
     * @param productCount :
     * @Description: 添加购物车
     * @return: com.mmall.common.ServerResponse<com.mmall.vo.CartVo>
     * @Author: yqy
     * @CreateDate: 2019/11/17 17:18
     */
    @RequestMapping("addCart.do")
    public ServerResponse<CartVo> addCart(HttpSession session, Integer productId, Integer productCount) {
        User user = (User) session.getAttribute(Const.CURRENT_USER);
        if (null == user) {
            return ServerResponse.createByError(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc());

        }
//       如果用户已登录,则加入购物车
        ServerResponse<CartVo> cartServerResponse = cartService.addCart(user.getId(), productId, productCount);
        return cartServerResponse;
    }   
    
}

Focus on documentation comments:

JDK API documentation storage path: download java SE Document, and then extract jdk-8-doc.zip will get a docs folder, you can get the API documentation

Note: the development process, we can add documentation comments when defining classes and methods, then generate API documentation via javadoc command, API documentation, mainly for functional description of classes, methods, properties. Further javadoc tool handles only the default class public or protected modified, interfaces, methods, properties, document annotation constructor.

If you need to extract the private modified content, increase -private option when using the javadoc command

javadoc command usage parameter that is described in detail:

api javadoc -d store the document path -windowtitle browser window title -doctitle the left of the document title -header title -version -author class name .java (Note: If you want to generate all the java classes this file API, then, you can use wildcards to replace the class name * .java .java)

Document annotation commonly used javadoc tags:

@author version of @version @param method parameter description @return method returns a value of type @throws @exception thrown thrown exception, the same exception action


Guess you like

Origin www.cnblogs.com/yuxiangyuan-cloud/p/12182250.html