编程知识 cdmana.com

Java常见错误合集

null 转基本类型

@Data
@NoArgsConstructor
@AllArgsConstructor
static class OneClass {
    private Double value;
}

@Test
public void nullToPrimitive() {
    OneClass oneClass = new OneClass(1.0);
    double value = oneClass.getValue();
    System.out.println(value);
    OneClass oneClass2 = new OneClass();
    value = oneClass2.getValue();
    System.out.println(value);
}

null指针异常

未完待续……

版权声明
本文为[eaglelihh]所创,转载请带上原文链接,感谢
https://www.cnblogs.com/eaglelihh/p/13960467.html

Scroll to Top