Java 基础 之 标识符

原链接 : http://www.verejava.com/?id=1699254299287

/*
标识符的命名规则:
1. 是以字母,数字,下滑线_和美元符号$ 组成
2. 不能以数字开头
3. 区分大小写
4. 不能是java的保留关键字
5. 最好是见名思意
*/
public class Identifier
{
    public static void main(String[] args)
    {
        //不能以数字开头
        //int 1number=1;

        //标识符区分大小写
        int b=2;
        int B=3;
        System.out.println(b);
        System.out.println(B);
        //不能是java 的保留关键字
        //int class=4;

        //年龄最好见名思意
        int age=30;
        //两个字符串相连接用加号 +
        System.out.println("年龄是:"+age);

    }
}

原链接 : http://www.verejava.com/?id=1699254299287

猜你喜欢

转载自blog.51cto.com/11960922/2120207