Results 1 to 3 of 3
  1. #1
    Jeffrod is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default 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:

  2. #2
    baf06 is offline Member
    Join Date
    Jan 2011
    Location
    Beirut, Lebanon
    Posts
    90
    Rep Power
    0

    Default

    did you try to fix this difference ? :
    class GraphMethods<E extends Comparable<E>>
    class ListGraph<E extends Comparable<E>> implements Graph<E>
    I am not sure about it but this is what i understand from your error
    "GraphMethods.java:57: cannot find symbol
    Click on REP and add to member reputation, if you find their advices/solutions effective.

  3. #3
    Jeffrod is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    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

  1. compareTo() problems...
    By falkon114 in forum New To Java
    Replies: 1
    Last Post: 01-28-2011, 09:08 PM
  2. using the compareTo method
    By anonymous445 in forum New To Java
    Replies: 3
    Last Post: 01-19-2011, 03:53 AM
  3. Sort with CompareTo
    By ScienceLife in forum New To Java
    Replies: 7
    Last Post: 12-01-2010, 01:08 PM
  4. need help wit this compareTo method
    By ShinTec in forum New To Java
    Replies: 4
    Last Post: 02-02-2010, 02:24 AM
  5. compareTo()
    By Tsiliadoros in forum Advanced Java
    Replies: 5
    Last Post: 10-03-2008, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •