File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Error in Simple Dot Com Game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in Simple Dot Com Game" Watch "Error in Simple Dot Com Game" New topic

Error in Simple Dot Com Game

Spandan Pandey

Joined: Feb 20, 2013
Posts: 10
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.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15084

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Error in Simple Dot Com Game
It's not a secret anymore!