Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null Pointer Exception String null [closed]

if( currentTimeslot.isEmpty()){
         System.out.println("Do stuff");
            }

How come I get a NullPointerException? How do I check whether a string is NULL and do stuff if it is? Whenever currentTimeslot is equals to NULL I get the error. Here is the console message:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at PM.ui.MainFrame.getJPanelTopMenu(MainFrame.java:382)
like image 937
Blaiz Avatar asked Jan 31 '26 19:01

Blaiz


1 Answers

Try the following

    if( currentTimeslot == null){
             System.out.println("Do stuff");
   }
like image 172
Obl Tobl Avatar answered Feb 03 '26 08:02

Obl Tobl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!