写一段程序,查看java中int和char类型的默认值

class Test{
    int a;
    char b;
    public void print(){
    System.out.println(a);
    System.out.println(b);
    }
}


public class Homework{
     
    public static void main(String[] args){
      Test per=new Test();
      per.print();
    }
}


结果:

0

char型的默认值为空,输出的是一个空格

int型是0

猜你喜欢

转载自blog.csdn.net/sd116460/article/details/80737133
今日推荐