• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Error in Simple Dot Com Game

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did some corrections and the .java file compiled without any error but the error began in the output
Here is my code..Is My conversion of the int random numbers into string and using in checkyourself method is wrong?If not then why the output error..the program gets stuck asking-enter the number perpetually.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're doing some strange things in lines 49 to 56.

In line 49, you're generating a random number. You're not using that anywhere. In lines 51 to 56, you are adding strings that contain "randomNum", "randomNum+1" and "randomNum+2" to a list. Note that those are literally those strings - it looks like you expect that these strings will be evaluated to contain the random number, plus one or two, but that is not what happens. If you use a variable name in a string literal, it's not going to be evaluated automatically.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic