• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot find symbol using input boxes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:


 
Johnny Maxwell
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic