注释、标识符、关键字

一、注释(提高程序可读性)

1、单行注释(//…)

public class HelloWorld {
    public static void main(String[] args) {
        //输出一个Helloworld,只能注释一行文字
        System.out.println("helloworld");
    }
}

2、多行注释

public class HelloWorld {
    public static void main(String[] args) {
        /*
            输出一个Helloworld
            输出一个Helloworld
            输出一个Helloworld
            输出一个Helloworld
            可以注释多行文字
        */
        System.out.println("helloworld");
    }
}

3、文档注释(JavaDoc:/** */)

public class HelloWorld {
    public static void main(String[] args) {
        /**
         * @Description HelloWorld
         * @Athor 功不唐捐,玉汝于成
         * */
        
        System.out.println("helloworld");
    }
}

4、示例


/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

二、标识符

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

Java48个关键字:

abstractassertbooleanbreakbytecasecatchcharclasscontinuedefaultdodoubleelseenumextendsfinalfinallyfloatforifimplementsimportintinterfaceinstanceoflongnativenewpackageprivateprotectedpublicreturnshortstaticstrictfpsuperswitchsynchronizedthisthrowthrowstransienttryvoidvolatilewhile

标识符注意点

1、所有的标识符都应该以字母、美元符$、或者下划线开始
2、首字母后可以是字母、美元符、下划线、或数字的任何字符组合
3**不能使用关键字作为变量名或方法名**
4、合法标识符举例:age、$salary、_value_ 、_1_value
5、非法标识符举例:13abc、-salary、#abd

示例:

public class Demo01 {
    public static void main(String[] args) {
        String Ahello = "dlikex";
        String hello = "dlikex";
        String _123dews = "dlikex";
        String $123dwd$ = "dlikex";
        String 王者荣耀 = "荣耀王者";
        System.out.println(王者荣耀);
    }
}
  • 13
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值