package Demo;
/**
- java中的常量类型:
- 常量–在程序的运行中固定不变的量
-
- 字符串常量:凡是使用双引号引起来的量都叫做字符串常量;例如:“ABC” “123” “abc123” “”
-
- 整数常量:直接写上的数字不包含小数点; 例如:1 100 -120
-
- 浮点数常量:直接写上的数字,包含小数; 例如:1.2 3.14 3.15 1.0
-
- 字符常量:凡是使用单引号引起来的单个字符,就是字符常量; 例如:‘a’ ‘A’ '中’
-
- 布尔常量:只有两种取值:true false
-
-
空常量:null
*/
public class Demo01Const {
public static void main(String[] args){
//字符串常量
System.out.println(“Hello,World!!!”);
System.out.println("");
System.out.println(“ABC!@#DEF”);//整数常量
System.out.println(120);
System.out.println(-250);//浮点数常量
System.out.println(3.14);
System.out.println(1.0);//字符常量:字符常量单引号中不能为空,且不能同时使用两个及更多字符
System.out.println(‘A’);
//System.out.println(’’);
//System.out.println(‘AB’);//布尔常量:
System.out.println(true);
System.out.println(false);//空常量:空常量不能直接打印输出
//System.out.println(null);
}
}
-