Java中一共有三种注释方法
1. 单行注释
//
可以写在行内的代码后,也可以写在代码上面或者下面,起到理解代码语句的作用,为了能很多的理解代码,最好写上代码的上面或者代码后面.
写在语句上面
//这个是URI的所有的查询key
Set<String> keys = uri.getQueryParameterNames();
写在语句右边
for (String temp : keys) {
String value = uri.getQueryParameter(temp);//通过key,获取value
}
2.多行注释
/**/
/*
删除15天的数据,如果有新的订单
*/
public final static int DB_DELETE_DAYS = 15;
3.文档注释
/**
*/
下面是截取Context.java中的注释.
/**
* File creation mode: allow all other applications to have read access to
* the created file.
* <p>
* Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this
* mode throws a {@link SecurityException}.
*
* @deprecated Creating world-readable files is very dangerous, and likely
* to cause security holes in applications. It is strongly
* discouraged; instead, applications should use more formal
* mechanism for interactions such as {@link ContentProvider},
* {@link BroadcastReceiver}, and {@link android.app.Service}.
* There are no guarantees that this access mode will remain on
* a file, such as when it goes through a backup and restore.
* @see android.support.v4.content.FileProvider
* @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION
*/
通过命令javadoc -d 命令可以生成文档. 如果代码中有中文注释的话,在生成文档时候会报错.
所以通过命令 javadoc -d targetDir sourceFile -encoding UTF-8 -charset UTF-8.
如果对javadoc命令不太熟悉,可以通过 javadoc --help命令去查询
用上述的注释如果想生成文档的时候换行,需要把注释添加<pre></pre>之间 或者在每一行后面添加</br>标签.
特别提醒,以后争取每周都要写一篇博客来记录.