• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem compiling  RSS feed

 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: carefully inspect the characters you used.
 
Katie Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!