注释、标识符、关键字

注释、标识符、关键字

Java中的注释

注释是帮助程序员理解程序的。书写注释是一种好习惯

java 注释有三种:

  • 单行注释:只能注释一行文字
  • 多行注释:可以注释一段文字
  • 文档注释
/**
 * @author gcbeen
 */
public class HelloWorld {
    // 单行注释
    /*
    多行注释
     */
    /**
     * 文档注释
     * @param args 主函数参数
     */
    public static void main(String[] args) {
        System.out.println("Hello, World!!!");
    }
}

标识符

  • 所有的标识符都应该以字母(A-Z 或者 a-z),美元符($),或者下划线(_)开始;
  • 首字符之后可以是字母(A-Z 或者 a-z)美元符($)、下划线()或数字的任何字符组合;
  • 不能使用关键字作为变量名或方法名;
  • 标识符是大小写敏感的
  • 可以使用中文命名,但是一般不建议这样去使用,也不建议使用拼音。
/** 
* @author gcbeen 
*/
public class HelloWorld {
    public static void main(String[] args) {
        String Ahello = "gcbeen";
        String hello = "gcbeen";
        String $hello = "gcbeen";
        String _hello = "gcbeen";

        String _vvhh = "gcbeen";
        // 避免使用汉字命名
        String 王者荣耀 = "gcbeen";
    }
}

关键字列表

abstract boolean break byte case
catch char const class continue
default do double else extends
final finally float for goto
if implements import instanceof int
interface long native new package
private protected public return short
static strictfp super switch this
throw throws transient try void
volatile while synchronized
posted @ 2022-09-06 10:29  gcbeen  阅读(39)  评论(0)    收藏  举报