• 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

compiler error "cannot find symbol"

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am returning int.

Isn't

intcompareTo(String anotherString)
Compares two strings lexicographically.


from the String Java doc the correct signature?
 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic