在我第一次交Java作业的时候,我还不知道要把整个文件夹一起上传,直接点来点去把两个.java文件上传了,感觉自己真是印证了啥叫画蛇添足。Eclipse也不会装,最后直接上某宝找人装的,感觉某宝真是万能。我越来越觉得编程并不是一件难事,但是入门的时候会有点难,有些时候真的就是被第一步达到了。还好我抗过了第一步,以后的路再继续好好走。
1.文档注释
①文档注释的格式:以/**开头,以*/结尾
@author标识一个类的作者@author description@deprecated指名一个过期的类或成员@deprecated description{@docRoot}指明当前文档根目录的路径Directory Path@exception标志一个类抛出的异常@exception exception-name explanation{@inheritDoc}从直接父类继承的注释Inherits a comment from the immediate surperclass.{@link}插入一个到另一个主题的链接{@link name text}{@linkplain}插入一个到另一个主题的链接,但是该链接显示纯文本字体Inserts an in-line link to another topic.@param说明一个方法的参数@param parameter-name explanation@return说明返回值类型@return explanation@see指定一个到另一个主题的链接@see anchor@serial说明一个序列化属性@serial description@serialData说明通过writeObject( ) 和 writeExternal( )方法写的数据@serialData description@serialField说明一个ObjectStreamField组件@serialField name type description@since标记当引入一个特定的变化时@since release@throws和 @exception标签一样.The @throws tag has the same meaning as the @exception tag.{@value}显示常量的值,该常量必须是static属性。Displays the value of a constant, which must be a static field.@version指定类的版本@version info要是在程序的最开头想写整个程序的注释的话,可以分段<p></p>这个和html语言很像
/** * <p>This is a class to calculate simple four operations, which includes plus,subtract, * multiple and divide.We can calculate two decimals, and the result will be left two * decimals. After you finishing your first calculation, you can continue to calculate * just by input the word "continue". If you want to stop calculate, you can just input * the word "finish" to stop the procedure.</p> * @author stacey * @date 20190314 * @version 1.0.0.20190314_beta * @param s to receipt the return key and to receipt the operator * @param a the first operation number * @param b the second operation number * @param c to receipt the operator * @param p the receipt the judging word to decide wheather to continue or finish */写注释是一个好习惯,在每个函数之前,每个比较难理解的步骤之后,变量的解释,变量命名也要驼峰命名法,要不然隔一段时间看自己的程序根本看不明白。
javadoc工具的位置
2.判断字符串是否相等要用equals函数,不能用两个等号
3.输出:System.out.println();输出之后会自动换行。System.out.print();输出之后不会自动换行。System.out.print();这个函数和c语言的print函数用法相同,可以用来控制变量输出格式,比如Syste.out.printf("%.2f",a*b);