Results 1 to 3 of 3
Thread: compareTo screwing with me
- 04-12-2011, 03:16 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
compareTo screwing with me
Hey i get this error when compiling:
"GraphMethods.java:57: cannot find symbol
symbol : method compareTo(E)
location: class java.lang.Object
etc"
The code in question looks like this:
if(current.compareTo(to)==0)
in this class:
class GraphMethods<E extends Comparable<E>>
both current and to is definately a E.
the strange thing is that the following code works without any problems whatsoever:
if(cmp.getDest().compareTo(e2)==0)
in this class:
class ListGraph<E extends Comparable<E>> implements Graph<E>
in the last case e2 is declared as E and getDest() returns a E.
I cant for the life of me see what i did differently in the classes (and yes i do import the exact same packages, only java.util.* in both).:mad:
- 04-12-2011, 03:53 PM #2
Member
- Join Date
- Jan 2011
- Location
- Beirut, Lebanon
- Posts
- 90
- Rep Power
- 0
did you try to fix this difference ? :
class GraphMethods<E extends Comparable<E>>I am not sure about it but this is what i understand from your errorclass ListGraph<E extends Comparable<E>> implements Graph<E>
"GraphMethods.java:57: cannot find symbolClick on REP and add to member reputation, if you find their advices/solutions effective.
- 04-12-2011, 05:04 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
well Graph is a interface with about a half dozen methods used in different classes(the ListGraph class for example) so i hope thats not the solution because it would mean id have to add all those methods to GraphMethods :(
After taking a break for some food i looked at my code again and i finally did notice (remember) a difference. The method in GraphMethods is declared as Static. Since im a bit iffy on what exactly it means im not sure how it would affect things or how i would fix it.
"static<E> List<ListEdge<E>> shortestPath(Graph graph, E from, E to)"
if the method in GraphMethods
"public ListEdge<E> getEdge(E e1, E e2)"
is the method in ListGraph
Similar Threads
-
compareTo() problems...
By falkon114 in forum New To JavaReplies: 1Last Post: 01-28-2011, 09:08 PM -
using the compareTo method
By anonymous445 in forum New To JavaReplies: 3Last Post: 01-19-2011, 03:53 AM -
Sort with CompareTo
By ScienceLife in forum New To JavaReplies: 7Last Post: 12-01-2010, 01:08 PM -
need help wit this compareTo method
By ShinTec in forum New To JavaReplies: 4Last Post: 02-02-2010, 02:24 AM -
compareTo()
By Tsiliadoros in forum Advanced JavaReplies: 5Last Post: 10-03-2008, 01:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks