Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help making Headfirst Java simple game code work  RSS feed

 
Gregoire Duchamp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay so I simply refuse to go on until I can make sense of this. The book asked me to update the buggy DotCom code into what I now have below. But while everything was working just fine before (minus the bug you were supposed to fix ith this update to the code), it now won't compile as it gives me the error: int[] cannot be converted to ArrayList<String>

Which is odd since according to the book it should now work. I tried looking online for help on how to put the array into the ArrayList but that just confounded me more and more. Also changing some stuff around just gave me similar problems (can't put a String array into the ArrayList<String>, can't put an int array into ArrayList<Integer>, etc). Some insight and help would be much appreciated.

 
Carey Brown
Bartender
Posts: 2993
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a couple of lines are missing. Here's what I had to do to get it to work.

Possibly a more elegant way of doing this but it works.
 
Gregoire Duchamp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Looks like a couple of lines are missing. Here's what I had to do to get it to work.

Possibly a more elegant way of doing this but it works.


Yeah that's what I figured, but the book just said the code was to work as given and I couldn't figure out how to get the randomdNum to fit into the ArrayList.
But this works just fine. Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!