java - I have a casting error (String to int) -


a friend , making simple game randomly picks 1 of names , user has guess until he/she gets right. , getting error saying: exception in thread "main" java.lang.numberformatexception: input string: "adam kovic". can please help?

package projectpackage;  import java.util.random; import java.util.scanner;  public class projectclass {     public static void main(string eth[]) {      int adam = integer.valueof("adam kovic");     int bruce = integer.valueof("bruce greene");     int joel = integer.valueof("joel ruben");     int spoole = integer.valueof("sean poole");     int larr = integer.valueof("lawrence sonntag");     int james = integer.valueof("james willems");     int matt = integer.valueof("matt peake");      random r = new random();     int num[] = { adam, bruce, joel, spoole, larr, james, matt };     } } 

you away making array of strings, each element being string 1 of names, , have randomized pick between 0 , 6; whichever number picked specific array element chosen. in code checking if player has picked correct name, compare user's input string string array element randomizer picked.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -