• 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

Problem compiling

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to compile this program that I got from my teacher, but I keep getting errors. Here is the code:



The last few lines are causing the problem (the "public String toString" part). I don't think that the return command likes the combination of strings, doubles, and integers. Any ideas?
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint: carefully inspect the characters you used.
 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These were the errors:

Multiple markers at this line
- This method must return a result of type
String
- Syntax error, insert ";" to complete
BlockStatements
- String cannot be resolved to a variable
- Syntax error on token "Invalid Character", =
expected
- Syntax error on token "Invalid Character", ;
expected
- Syntax error on token(s), misplaced
construct(s)
- of cannot be resolved to a type
Thanks!
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It'd be best to copy and paste the error messages exactly as displayed, and UseCodeTags to preserve the formatting. Also be sure to UseCodeTags for your code. I added them to your original post.

In any case, look carefully at the quote characters on line 24. See anything amiss?
 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know it's having a problem with the quotation marks, but it seems like I have matching sets and I've used double quotes before, so I'm really not sure what the problem is. Can you help?
 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I erased and rewrote the code for that part, and now the first quote block shows up blue like the other one. I hit save, and the error message went away. I'm still interested in understanding what you were seeing in the character. But the code seems to be working now, so thanks!
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The characters used to delimit the first string are not double quote characters. They are "smart quote" characters from a word processor. They are not valid to use in Java.

Did you use Word or some other unsuitable program to type this code in? Or is this how you received it from the teacher? If the latter, he or she is being very sloppy.
 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That explains it! Thank you! I copied the code from a word document my teacher sent us. That explains why when I erased and retyped it, the quotes worked. Thanks, again!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic