This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Cattle Drive and the fly likes compiler error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "compiler error "cannot find symbol"" Watch "compiler error "cannot find symbol"" New topic

compiler error "cannot find symbol"

Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41

I have import java.util.*;

but get a compiler error of "cannot find symbol" at ...

return string2.compareTo(string1);

with a marker under the dot.

Please help. OOP-3 is kicking my butt.
Carol Murphy
village idiot

Joined: Mar 15, 2001
Posts: 1202
Did you double check your syntax prior to this line?
Actually, are you returning a String or an int or something else with this method?
I looked at compareTo() in the String class, and didn't find a method with this signature. The other place I checked didn't have a method with this signature, either.
[ July 27, 2008: Message edited by: Carol Murphy ]
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
I am returning int.


intcompareTo(String anotherString)
Compares two strings lexicographically.

from the String Java doc the correct signature?
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
OK - got it. For some bizarro reason up in the method argument list, I had typed string1 and string2 as Objects, rather than String. Once I correctly typed each as String, it works fine.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: compiler error "cannot find symbol"
It's not a secret anymore!