常量:在程序运行期间,固定不变的量

常量分类:

1.字符串常量:凡是用双引号引起来的部分,叫字符串常量,例如"AC","123"

2.整数常量:没有小数点的数字 如123

3.浮点数常量:有小数点的数字 如0.0 ,123.3

4.字符常量:凡是用单引号引起来的单个字符,叫字符常量 '3','A','中'

5.布尔常量:true,false

6.空常量: null   (代表没有任何数据)

public class Demo01Const{
	public static void main(String[] args)
	{
		//字符串常
		System.out.println("ABC");
		System.out.println("");// 表示内容为空
		System.out.println("123");
		
		//整数常量
		System.out.println(123);
		System.out.println(-12);
		
		//浮点型常量
		System.out.println(3.14);
		System.out.println(0.0);
		
		//布尔型常量
		System.out.println(true);
		System.out.println(false);
		
		//字符常量
		System.out.println('A');
		System.out.println('6');
		/////System.out.println(''); //两个单引号中间必须有且仅有一个字符,没有不行
		
		//空常量
		////System.out.println(null);//空常量不能直接用来打印输出
		
	}
}

  

相关文章:

  • 2021-06-08
  • 2021-06-27
  • 2022-01-15
  • 2022-01-16
  • 2021-09-14
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-14
  • 2021-09-24
  • 2022-02-24
  • 2021-10-12
  • 2022-02-18
  • 2021-12-23
  • 2021-09-13
相关资源
相似解决方案