System.out.println(Objects.hashCode(obj));
        System.out.println(Objects.toString(obj));
        System.out.println(Objects.requireNonNull(obj, "obj参数不能为空"));

output:

0
null
Exception in thread "main" java.lang.NullPointerException: obj参数不能为空
    at java.base/java.util.Objects.requireNonNull(Objects.java:246)
    at ObjectTest.main(ObjectTest.java:9)

 

相关文章:

  • 2021-11-03
  • 2022-02-14
  • 2022-12-23
  • 2021-07-30
  • 2021-10-17
  • 2022-12-23
  • 2021-09-24
猜你喜欢
  • 2021-07-27
  • 2021-05-13
  • 2022-12-23
  • 2021-11-17
  • 2021-06-25
  • 2022-02-16
  • 2021-12-16
相关资源
相似解决方案