如何在 java 中添加评论框?
How do you add a comment box in java?
我正在 java 中为 class 开发一个项目,我需要在我的每个方法上方添加一个注释框来解释每个方法的作用。它应该看起来像这样:
***** *** ** ** **(星号线)*************************** *************************************************
*@param
*
****** *** ** ** ** **(另一行)************************** **********************************************
我正在使用 eclipse,我知道有一个创建此框的快捷方式,但我似乎不记得它或在网上找到它...
在主菜单中 Window -> 首选项
在左边的树上
Java->代码风格->CodeTemplates
右侧面板select评论->方法和打印右下角文本区的图案
转到 eclipse > windows > 首选项 > java > 模板
点击 NEW
现在为您的模式命名并添加描述并提供以下模式
/*****************************************************************************************
* ${cursor}This is default description for this method. Kindly remove this type the actual
* usage and other relevant information for the method as description.
* @since ${date}
* @param paramName Parameter description
* @return <Description of return value. Remove this tab for return type void.>
* @throws ExceptionClass Description of the exception reason or scenario
*****************************************************************************************/
/*
* Author ${user}
* Version <Enter the version of the product/project for this method.>
* History Updated By Update Date Update Reason
* ============== =========== ================================================
*/
使用上下文作为 java
现在最终显示创建任何 class 并且在引入方法之前添加方法只需开始输入上述模板的名称然后按 CTRL+SPACE 和 select 你的模板和 boom 你的方法被阅读以进行描述。
最好使用 JavaDoc 记录您的每个方法并解释它们的作用、它们的参数、它们的作用 return 以及它可能抛出的任何异常。
/**
* This is proper JavaDoc notation. It starts with a forward slash, two asterisks
* and then an asterisk per line. When it ends, we use the combo asterisk forward slash
*/
识别参数和return类型时,使用@
字符:
/**
* method add2 takes an integer and adds
* 2 to it. It then returns the new integer
*
* @param someInt the integer we will add 2 to
* @return integer the new integer after 2 was added
*/
public int add2(int someInt) {
int integer = someInt + 2;
return integer;
}
我正在 java 中为 class 开发一个项目,我需要在我的每个方法上方添加一个注释框来解释每个方法的作用。它应该看起来像这样:
***** *** ** ** **(星号线)*************************** ************************************************* *@param
*
****** *** ** ** ** **(另一行)************************** **********************************************
我正在使用 eclipse,我知道有一个创建此框的快捷方式,但我似乎不记得它或在网上找到它...
在主菜单中 Window -> 首选项 在左边的树上 Java->代码风格->CodeTemplates 右侧面板select评论->方法和打印右下角文本区的图案
转到 eclipse > windows > 首选项 > java > 模板
点击 NEW
现在为您的模式命名并添加描述并提供以下模式
/*****************************************************************************************
* ${cursor}This is default description for this method. Kindly remove this type the actual
* usage and other relevant information for the method as description.
* @since ${date}
* @param paramName Parameter description
* @return <Description of return value. Remove this tab for return type void.>
* @throws ExceptionClass Description of the exception reason or scenario
*****************************************************************************************/
/*
* Author ${user}
* Version <Enter the version of the product/project for this method.>
* History Updated By Update Date Update Reason
* ============== =========== ================================================
*/
使用上下文作为 java
现在最终显示创建任何 class 并且在引入方法之前添加方法只需开始输入上述模板的名称然后按 CTRL+SPACE 和 select 你的模板和 boom 你的方法被阅读以进行描述。
最好使用 JavaDoc 记录您的每个方法并解释它们的作用、它们的参数、它们的作用 return 以及它可能抛出的任何异常。
/**
* This is proper JavaDoc notation. It starts with a forward slash, two asterisks
* and then an asterisk per line. When it ends, we use the combo asterisk forward slash
*/
识别参数和return类型时,使用@
字符:
/**
* method add2 takes an integer and adds
* 2 to it. It then returns the new integer
*
* @param someInt the integer we will add 2 to
* @return integer the new integer after 2 was added
*/
public int add2(int someInt) {
int integer = someInt + 2;
return integer;
}