Friday, 15 January 2010

java - Double will not assign value from int array -


In my program, I load some custom variables from a text file to use. This is such a way.

  public int [] getGameSettings () {string [] rawGame = new string [100]; String [] gameSettingsString = new string [6]; Int [] gameSettings = New Ent [6]; Int finalLine = 0; Int reading = 0; Try to open the {// file which is the first / command line parameter file inputstream firststrument = new file inputstream ("gamingtxtxt"); BufferedReader br = new BufferedReader (new InputStreamReader (fstream)); String stroke; // line line line read line int = 0; While ((strLine = br.readline ())! = Null) {// Store it Raw game [line] = strline; Line ++; } // input stream in. Stop it (); Reading = line; } Hold (exception e) {// exception if any system. Err.println ("error:" + e.getMessage ()); } (Intra A = 0; a & lt; reading; A ++) {If the raw game [A] .sbstring (0,1) .acquills ("/") {gameSettingsString [finalLine] = rawGame [ A]; for finalLine ++;}} (int b = 0; b & lt; last line; b ++) {game settings [b] = integer.} Return game settings;}   

I call that method from another class and save the array as game settings, then do the following:

  contestedMovementPercent = (game settings [1] / 100);   

Contestant movement always appears at 0.0 Even if I print the game settings [1] it comes out precisely what it should be. Freedom is a double per day game settings is an integer in both classes.

I have no need? I thought that int can be used like this.

Divided by int, so it calculates for the first time, it is in the form of an int and then it is in double digits Converts does it Game settings [1] / 100.0 change in will count it as a double.

No comments:

Post a Comment