File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in Simple Dot Com Game" Watch "Error in Simple Dot Com Game" New topic
Author

Error in Simple Dot Com Game

Spandan Pandey
Greenhorn

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: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error in Simple Dot Com Game
 
Similar Threads
Simple Dot Com Game
Head First Java - pg 135 - ArrayList and Compile Errors
New DotComClass
While working from Head first java, I came across this problem... Please help
ArrayList problem. Head First Java, p. 138 - 139