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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -