Current location - Recipe Complete Network - Complete cookbook of home-style dishes - I just started learning java and made a menu. Why didn't he quit after pressing quit? Seek an answer
I just started learning java and made a menu. Why didn't he quit after pressing quit? Seek an answer
j menuitem m 14 = new j menuitem(" exit ");

m 14 . addactionlistener(this);

m 1 . add(m 14);

And if (e.getActionCommand()== "exit ").

system . exit(0);

This should be changed to if(e.getActionCommand ()). Equal to ("exit") {

system . exit(0);

} This is the standard.