数据类型 默认值
byte 0
short 0
int 0
long 0
float 0.0
double 0.0
char 'u0000'
boolean false
public class demo1 {
    public static void main(String[] args) {

        Variable v = new Variable();
        System.out.println("byte类型的初始值为" + v.byteNum);
        System.out.println("short类型的初始值为" + v.shortNum);
        System.out.println("int类型的初始值为" + v.intNum);
        System.out.println("long类型的初始值为" + v.longNum);
        System.out.println("float类型的初始值为" + v.floatNum);
        System.out.println("double类型的初始值为" + v.doubleNum);
        System.out.println("boolean类型的初始值为" + v.flag);
    }
}
class Variable {
    byte byteNum;
    short shortNum;
    int intNum;
    long longNum;
    float floatNum;
    double doubleNum;
    boolean flag;
}


byte类型的初始值为0
short类型的初始值为0
int类型的初始值为0
long类型的初始值为0
float类型的初始值为0.0
double类型的初始值为0.0
boolean类型的初始值为false

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-08-06
  • 2021-11-29
  • 2021-11-29
  • 2022-01-31
猜你喜欢
  • 2021-11-29
  • 2021-11-29
  • 2021-12-09
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案