public static String s;
public static void main(String[] args) {
if (s.length() == 0) {
System.out.println("11111");
} else {
System.out.println("afafa");
}
}
控制台窗口报错如下:
Exception in thread "main" java.lang.NullPointerException
at com.merck.app.coronavirus.application.schedule.FastaStatusJob.main(FastaStatusJob.java:262)
解决方案:将nul更改为""
public static String s=””;
public static void main(String[] args) {
if (s.length() == 0) {
System.out.println("11111");
} else {
System.out.println("afafa");
}
}