【JAVA】java做注释
2015-09-02 11:35
363 查看
在写《第一行代码》第二章ActivityTest项目中, 写到在SecondActivity中构造Intent跳转函数
这个函数是为了在其他Activity跳转到SecondActivity时,能够直接调用该函数,直接了解调用参数。
写完以后,我想的是在其他Activity调用该函数,虽然能够看到参数个数,名字,但是缺少文档解释还是不是很了解每个参数的含义,所以我想用javadoc,但是不知道javadoc的用法,最后查阅的使用结果如下:
在其他Activity调用该方法的情况如下:
完成。
大家可以参看。
然后我突然想了解下java注释的一些注释规范:
查阅如下:转自: http://blog.csdn.net/shiyuezhong/article/details/8205281
注释原则
1、基本注释(必须加)
(a) 类(接口)的注释
(b) 构造函数的注释
(c) 方法的注释
(d) 全局变量的注释
(e) 字段/属性的注释
备注:简单的代码做简单注释,注释内容不大于10个字即可,另外,持久化对象或VO对象的getter、setter方法不需加注释。具体的注释格式请参考下面举例。
2、特殊必加注释(必须加)
(a) 典型算法必须有注释。
(b) 在代码不明晰处必须有注释。
(c) 在代码修改处加上修改标识的注释。
(d) 在循环和逻辑分支组成的代码中加注释。
(e) 为他人提供的接口必须加详细注释。
备注:此类注释格式暂无举例。具体的注释格式自行定义,要求注释内容准确简洁。
注释格式:
1、单行(single-line)注释:“//……”
2、块(block)注释:“/*……*/”
3、文档注释:“/**……*/”
4、javadoc 注释标签语法
@author 对类的说明 标明开发该类模块的作者
@version 对类的说明 标明该类模块的版本
@see 对类、属性、方法的说明 参考转向,也就是相关主题
@param 对方法的说明 对方法中某参数的说明
@return 对方法的说明 对方法返回值的说明
@exception 对方法的说明 对方法可能抛出的异常进行说明
参考举例
1. 类(接口)注释
例如:
/**
* 类的描述
* @author Administrator
* @Time 2012-11-2014:49:01
*
*/
public classTest extends Button
{
……
}
2. 构造方法注释
例如:
public class Test extends Button
{
/**
* 构造方法 的描述
* @param name
* 按钮的上显示的文字
*/
public Test(String
name){
……
}
}
3. 方法注释
例如
public class Test extends Button
{
/**
* 为按钮添加颜色
*@param color
按钮的颜色
*@return
*@exception (方法有异常的话加)
* @author Administrator
* @Time2012-11-20 15:02:29
*/
public voidaddColor(String
color){
……
}
}
4. 全局变量注释
例如:
public final class String
implements java.io.Serializable,
Comparable<String>,CharSequence
{
/** The value is used for characterstorage.
*/
private final char value[];
/** The offset is the first index of thestorage
that is used. */
private final int offset;
/** The count is the number of charactersin
the String. */
private final int count;
/** Cache the hash code for the string */
private int hash; //
Default to 0
……
}
5. 字段/属性注释
例如:
public class EmailBody implements Serializable{
private String id;
private String senderName;//发送人姓名
private String title;//不能超过120个中文字符
private String content;//邮件正文
private String attach;//附件,如果有的话
private String totalCount;//总发送人数
private String successCount;//成功发送的人数
private Integer isDelete;//0不删除 1删除
private Date createTime;//目前不支持定时 所以创建后即刻发送
privateSet<EmailList> EmailList;
……
}
public static void actionStart(Context context, String param1, String param2) { Intent intent = new Intent(context, SecondActivity.class); intent.putExtra("param1", param1); intent.putExtra("param2", param2); context.startActivity(intent); }
这个函数是为了在其他Activity跳转到SecondActivity时,能够直接调用该函数,直接了解调用参数。
写完以后,我想的是在其他Activity调用该函数,虽然能够看到参数个数,名字,但是缺少文档解释还是不是很了解每个参数的含义,所以我想用javadoc,但是不知道javadoc的用法,最后查阅的使用结果如下:
/**
* The actionStart method of the SecondActivity.
* This method is called when an Activity wants to skip to SecondActivty.
*
* @param context
* The start Activity of intent
* @param param1
* username
* @param param2
* password
* @throws ServletException
* if an error occurred
*/
public static void actionStart(Context context, String param1, String param2) { Intent intent = new Intent(context, SecondActivity.class); intent.putExtra("param1", param1); intent.putExtra("param2", param2); context.startActivity(intent); }
在其他Activity调用该方法的情况如下:
完成。
大家可以参看。
然后我突然想了解下java注释的一些注释规范:
查阅如下:转自: http://blog.csdn.net/shiyuezhong/article/details/8205281
注释原则
1、基本注释(必须加)
(a) 类(接口)的注释
(b) 构造函数的注释
(c) 方法的注释
(d) 全局变量的注释
(e) 字段/属性的注释
备注:简单的代码做简单注释,注释内容不大于10个字即可,另外,持久化对象或VO对象的getter、setter方法不需加注释。具体的注释格式请参考下面举例。
2、特殊必加注释(必须加)
(a) 典型算法必须有注释。
(b) 在代码不明晰处必须有注释。
(c) 在代码修改处加上修改标识的注释。
(d) 在循环和逻辑分支组成的代码中加注释。
(e) 为他人提供的接口必须加详细注释。
备注:此类注释格式暂无举例。具体的注释格式自行定义,要求注释内容准确简洁。
注释格式:
1、单行(single-line)注释:“//……”
2、块(block)注释:“/*……*/”
3、文档注释:“/**……*/”
4、javadoc 注释标签语法
@author 对类的说明 标明开发该类模块的作者
@version 对类的说明 标明该类模块的版本
@see 对类、属性、方法的说明 参考转向,也就是相关主题
@param 对方法的说明 对方法中某参数的说明
@return 对方法的说明 对方法返回值的说明
@exception 对方法的说明 对方法可能抛出的异常进行说明
参考举例
1. 类(接口)注释
例如:
/**
* 类的描述
* @author Administrator
* @Time 2012-11-2014:49:01
*
*/
public classTest extends Button
{
……
}
2. 构造方法注释
例如:
public class Test extends Button
{
/**
* 构造方法 的描述
* @param name
* 按钮的上显示的文字
*/
public Test(String
name){
……
}
}
3. 方法注释
例如
public class Test extends Button
{
/**
* 为按钮添加颜色
*@param color
按钮的颜色
*@return
*@exception (方法有异常的话加)
* @author Administrator
* @Time2012-11-20 15:02:29
*/
public voidaddColor(String
color){
……
}
}
4. 全局变量注释
例如:
public final class String
implements java.io.Serializable,
Comparable<String>,CharSequence
{
/** The value is used for characterstorage.
*/
private final char value[];
/** The offset is the first index of thestorage
that is used. */
private final int offset;
/** The count is the number of charactersin
the String. */
private final int count;
/** Cache the hash code for the string */
private int hash; //
Default to 0
……
}
5. 字段/属性注释
例如:
public class EmailBody implements Serializable{
private String id;
private String senderName;//发送人姓名
private String title;//不能超过120个中文字符
private String content;//邮件正文
private String attach;//附件,如果有的话
private String totalCount;//总发送人数
private String successCount;//成功发送的人数
private Integer isDelete;//0不删除 1删除
private Date createTime;//目前不支持定时 所以创建后即刻发送
privateSet<EmailList> EmailList;
……
}
相关文章推荐
- Java____随机数+时间戳+拼接=图片命名
- Java加密技术(一)——BASE64与单向加密算法MD5&SHA&MAC
- Spring Assert 断言
- Set file permission in Java(Java 中文件权限的设置)
- 在eclipse里安装pydev
- JavaBean组件在JSP文档中的应用
- Java中四种引用类型
- Hibernate学习笔记
- 现阶段要学习JAVA技术
- java编程之Noncompliant; %n should be used in place of \n to produce the platform-specific line separato
- [leetcode-87]Scramble String(java)
- Java transient关键字使用小记
- Java--Swing组件使用问题详解
- Java--Encode
- java编程之Exception handlers should preserve the original exception
- SpringMVC 使用JSR-303进行校验 @Valid
- SSH项目问题【六】java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 看马士兵javase视频看第2章基础语法发现错误
- Java性能优化(7):改写equals时遵守通用约定
- 解决Eclipse快捷键被其他软件占用