Bla*_*aiz 3 java nullpointerexception
if( currentTimeslot.isEmpty()){
System.out.println("Do stuff");
}
Run Code Online (Sandbox Code Playgroud)
我怎么得到一个NullPointerException?如何检查字符串是否存在NULL并在存在时执行操作?每当currentTimeslot等于NULL我就会收到错误。这是控制台消息:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at PM.ui.MainFrame.getJPanelTopMenu(MainFrame.java:382)
Run Code Online (Sandbox Code Playgroud)
尝试以下操作
if( currentTimeslot == null){
System.out.println("Do stuff");
}
Run Code Online (Sandbox Code Playgroud)