wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Cannot find symbol using input boxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot find symbol using input boxes" Watch "Cannot find symbol using input boxes" New topic
Author

Cannot find symbol using input boxes

Johnny Maxwell
Greenhorn

Joined: Aug 29, 2011
Posts: 2
I feel really bad asking questions on a forum (especially when having only this one post so far), but after spending hours with the Google and reading all the pages I can find on input boxes, strings, and what not; along with scouring my text book for anything (I'm convinced this textbook serves no purpose other than doorstop) I've feel I've ran my head into a wall and can't find any other way to do this.

Here's what I have written code wise:



And every time I run to compile it I get the following errors:

[Captain_Steve@google Week 5 Projects]$ javac HighScore.java
HighScore.java:27: cannot find symbol
symbol : method String(java.lang.String)
location: class HighScore
String name = String(inputValue2);
^
HighScore.java:42: cannot find symbol
symbol : method String(java.lang.String)
location: class HighScore
String nameloop = String(inputValue4);


I'm assuming I'm having some kind of problem with using strings, naming strings, or understanding the entire concept of how strings are suppose to work. This is basically a line for line conversion from a scanner input method to a user input box method, so I'm fairly confident that it isn't something with how I have everything ordered and done up, since I can get the other one to compile and run the way it's suppose to.

And since It may be of use, the goal of this is to enter a bunch of names and numbers and have the highest number be displayed along with the name (like a bunch of test scores or such). I'm not really sure what else may be of value.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10329
    
    8

Welcome to the Ranch.

To make your compiler errors go away, change it to

However, that is a moot point. You have already defined inputValue2 and inputValue4 as strings and the erroneous (String) is not really required.

The syntax SomeClass someClassVariable=(SomeClass)otherClassvariable; is called type casting. What it essentially means is that you are casting an object of typeB to typeA object. This will work only if there is a castable relationship between typeA and typeB, else you will get a ClassCastException. The book will contain an explanation on this, most probably in the inheritance section.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Johnny Maxwell wrote:


I would remove such comments. That it is a variable and that is it used for the score is apparent by the context and name.
The thing is that if you later change the variable name (through refactoring) you'll end up with confusing code:



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Johnny Maxwell
Greenhorn

Joined: Aug 29, 2011
Posts: 2
Thank you all for your help; it works wonderfully. I spent hours pouring over this text book on casting strings and what not, and it never goes much beyond "hello world" style examples.

Thank you all again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find symbol using input boxes