Java的关键字和标识符

Java关键字

abstract assert boolean break byte
case catch char class const
continue default do double else
enum extends final finally float
for goto if implements import
instanceof int interface long native
new package private protected public
return strictfp short static super
switch synchronized this throw throws
transient try void volatile while

Java标识符

Java所有的组成部分都需要名字。类名变量名方法名都被称为标识符

  • 所一的标识符都应该以字母(A-Z)或(a-z)、美元符($)、下划线(_)开始
  • 首字符之后可以是字母(A-Z)或(a-z)、美元符($)、下划线(_)、数字组合
  • 不能使用关键字作为变量名或方法名
  • 标识符是大小写敏感的
  • 可以使用中文命名,但是不建议这样使用
public class Demo01 {
    public static void main(String[] args) {
        String Abc = "小明";
        String abc = "小明";
        String $bc = "小明";
        String _bc = "小明";
        //String 1bc = "小明";
        System.out.println(Abc);
        System.out.println(abc);
        System.out.println($bc);
        System.out.println(_bc);
        //System.out.println(1bc);
    }
}
posted @ 2021-03-09 20:40  杰myx  阅读(68)  评论(0)    收藏  举报