一、注释(提高程序可读性)
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个关键字:
abstract、assert、boolean、break、byte、case、catch、char、class、
continue、default、do、double、else、enum、extends、final、
finally、float、for、if、implements、import、int、interface、
instanceof、long、native、new、package、private、protected、
public、return、short、static、strictfp、super、switch、
synchronized、this、throw、throws、transient、try、void、
volatile、while。
标识符注意点
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(王者荣耀);
}
}