Unreachable code in Java -


i don't "unreachable code" means ?

here in last line of code double probabilityofwin = wins / (wins + loses); says unreachable code.

import java.util.random;   public class crapsgame {     public static final int games = 9999;  public static void main(string[] args) {     random randomgenerator1 = new random();     random randomgenerator2 = new random();     random randomgenerator3 = new random();     random randomgenerator4 = new random();      int dice1 = randomgenerator1.nextint(6) + 1;     int dice2 = randomgenerator2.nextint(6) + 1;      int comeoutsum = dice1 + dice2;     int point = 0;      // comeout roll      if (comeoutsum == 7 || comeoutsum == 12)         system.out.println("wins");     else if ( comeoutsum == 2 || comeoutsum == 3 || comeoutsum == 12)         system.out.println("loses");     else          point = comeoutsum;      int wins = 0;     int loses = 0;       while(games <= 9999)     {         dice1 = randomgenerator3.nextint(6) + 1;         dice2 = randomgenerator4.nextint(6) + 1;         int sum = dice1 + dice2;          if (sum == point)             wins++;         else if (sum == 7)             loses++;     }      double probabilityofwin = wins / (wins + loses);   } 

}

this loop here:

while(games <= 9999) {     ... } 

resolves while (true) because value of games never modified. code comes after (in case, double probabilityofwin = wins / (wins + loses);) deemed unreachable.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -