java - Receiving an 'else' without 'if' error -
import javax.swing.joptionpane; public class cortana2 { public static void main(string[] args) throws exception { //declaring variables (add more commands) string command; // command stay same // strings below commands put in string steam; string league; league=("league"); steam=("steam"); command= joptionpane.showinputdialog("give valid command"); if (command == null) { joptionpane.showmessagedialog(null, "this not valid command. if have forgotten commands valid, please refer devon assistance"); joptionpane.getrootframe().dispose(); } else if (command == league) { runtime.getruntime().exec("\"d:/leagueclient.exe\""); } else if (command == steam) { runtime.getruntime().exec("\"c:/program files (x86)/steam/steam.exe\""); } } }
not 100% sure why i'm getting error. i've seen others said remove semicolons 'if' statements nothing executes when run program , type in commands. sorry if seems poorly formatted.
if (command == null);
don't put ";" @ end of if/else statements.
but nothing executes when run program , type in commands
don't use ==
compare string.
instead use string.equals(...)
method
also variable names should not start upper case character.
Comments
Post a Comment