java常量

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

分类:
1、字符串常量:凡是用双引号引起来的部分,叫做字符串常量。如:"abc","hello"
2、整数常量:直接写上的数字,没有小数点 如:200,300,-200
3、浮点数常量: 直接写上的数字,有小数点。如 2.23,3.14
4、字符常量:凡是用单引号引起来的单个字符,就是字符常量 如:'2','a' '中'
5、布尔常量:只有两种取值。ture  false
空常量:null 代表没有任何数据。
*/
public class Demo01Const{
    public static void main(String[] args){
    //字符串常量
    System.out.println("Hello");
    System.out.println("");//字符串两个引号中间为空
    System.out.println("Word");
    
    //整数常量
    System.out.println(30);
    System.out.println(20);
    
    //浮点数常量
    System.out,println(3.14);
    System.out,println(1.23);
    
    //字符常量
    System.out.println('A');
    System.out.println('6');
    //System.out.println(''); 两个单引号中间必须有且仅有一个字符,没有也不行
    //System.out.println('AB'); 不能有两个
    
    //布尔常量
    System.out.println(true);
    System.out.println(false);
    
    //空常量。空常量不能直接用来打印输出
    //System.out.println(null); 不能这样写
    
    }
}

 

posted @ 2019-10-14 10:19  hehe哒  阅读(201)  评论(0编辑  收藏  举报