Please help...stuck with compareTo when comparing objects in ListNodes

I'm writing a SortedLinkedList class that extends MyLinkedList that I wrote and I need to write a sort but i keep getting this error message when I try to compare two objects in the listnodes
cannot resolve symbol method compareTo(java.lang.Object)
     Object a = get(x); //get returns an object at the listnode x(index)
     Object b = get(y);
if(a.compareTo(b) >= 0) //Error message
etc.....

If you want to sort the list nodes, you can make a
compareTo method for each node which casts its Object
to a Comparable and calls compareTo on the arg's (arg
is the other list node) Object.     would i put this in MySortedLinkedList class?
public int compareTo(Object o)
          return this.compareTo((Object)o).this);
          //this is the best i can come up with so far but it doesn't help me at all

Similar Messages

  • Please help - Stuck with JTable???

    Hi everyone, i have had this problem now for ages and really wanna solve it - hope u can help!
    I have a Jtable and basically column 3 has a value in it, column 4 is editable and takes in a value that the user enters. I need to take the value from column 3 and multiply it by the number entered into column 4 to update column 5 with the result.
    I have looked over and over the API for this and saw working examples, however i am using my own table model class and finding it hard to adapt these examples to work with my code, below is my table model class and the method i have written to try undertake this piece of functionality, can anyone help me get this working - dukes!!
    class ResultSetTableModel extends AbstractTableModel {
    protected Vector columnHeaders;
    protected Vector tableData;
    protected Vector rowData;
    private Connection con;    
    private int column_count;
    int QTY_COLUMN = 4;
    private double value;
    private JTable table;
    public void fillTableModel (ResultSet result) throws SQLException {
         ResultSetMetaData rsmd = result.getMetaData();
         int count = rsmd.getColumnCount();
         columnHeaders = new Vector();
         tableData = new Vector ();
         for (int i = 1; i <= count; i++)
              columnHeaders.addElement(rsmd.getColumnName (i));
              //System.out.println(rsmd.getColumnName(i));
         columnHeaders.addElement("Qty");
         columnHeaders.addElement("Total");
         while (result.next())
              rowData = new Vector (count);
              int row = 0;
              for (int i = 1; i <= count ; i++)
                   rowData.addElement (result.getObject(i));          
              rowData.addElement("4");
              rowData.addElement("0.00");
              tableData.addElement (rowData);
         result.close();
         fireTableDataChanged();
    public int getColumnCount ()
         return columnHeaders.size();     
    public int getRowCount ()
         return tableData.size();          
    /*public Object getValueAt (int row, int column)
         Vector rowData = (Vector) (tableData.elementAt (row));   
         return rowData.elementAt (column);
    public Object getValueAt(int row, int col){  //This is the method i have written
         int sum = 0; 
         if(col == 5) {   
         try {     
              sum = Integer.parseInt((String)getValueAt(row, 3)) * Integer.parseInt((String)getValueAt(row,4));//Need to take a user input here instead of a value - i think!   
         catch (Exception e)    { //Sum above not working as column 5 displays the number 4 in each row     
              sum = 4;   
         return (new Double(sum)); 
         else  {   
              Vector rowData = (Vector) (tableData.elementAt (row));   
              return rowData.elementAt (col); 
    public boolean isCellEditable (int row, int column )
         return (column == QTY_COLUMN);
    public String getColumnName (int column)
         return (String) (columnHeaders.elementAt (column));
    public void emptyColumn(int column){   
         int rowCount = tableData.size();       
         for (int i = 0; i < rowCount; i++)    {       
              Vector rowData = (Vector)tableData.elementAt(i);               
              rowData.setElementAt("", column);   
         fireTableDataChanged();
    public void setValueAt(Object value, int row, int column) {
             ((Vector)tableData.elementAt(row)).setElementAt(value, column);
             fireTableCellUpdated(row, 5);
    }Can anyone please help and yes im desperate, he he
    Thanks in advance

    Here's something:import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class Test extends JFrame {
        public Test () {
            getContentPane ().setLayout (new BorderLayout ());
            getContentPane ().add (new JTable (new TestModel ()));
            setDefaultCloseOperation (EXIT_ON_CLOSE);
            setTitle ("Test");
            pack ();
            setLocationRelativeTo (null);
            show ();
        public static void main (String[] parameters) {
            new Test ();
        private class TestModel extends AbstractTableModel {
            private java.util.List data;
            public TestModel () {
                data = new ArrayList ();
                data.add (new Pair (3, 4));
                data.add (new Pair (1, 7));
                data.add (new Pair (2, 9));
                data.add (new Pair (6, 5));
                data.add (new Pair (8, 0));
            public int getRowCount () {
                return data.size ();
            public int getColumnCount () {
                return 3;
            public Object getValueAt (int r, int c) {
                Pair pair = (Pair) data.get (r);
                int value;
                switch (c) {
                    case 0:
                        value = pair.a;
                        break;
                    case 1:
                        value = pair.b;
                        break;
                    default:
                        value = pair.a * pair.b;
                        break;
                return new Integer (value);
            public Class getColumnClass (int c) {
                return Integer.class;
            public boolean isCellEditable (int r, int c) {
                return c < 2;
            public void setValueAt (Object wrappedValue, int r, int c) {
                Pair pair = (Pair) data.get (r);
                int value = ((Integer) wrappedValue).intValue ();
                switch (c) {
                    case 0:
                        pair.a = value;
                        break;
                    case 1:
                        pair.b = value;
                        break;
                fireTableRowsUpdated (r, r);
            private class Pair {
                public int a;
                public int b;
                public Pair (int a, int b) {
                    this.a = a;
                    this.b = b;
    }Kind regards,
      Levi

  • HT1553 Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!

    Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!
    http://support.apple.com/kb/HT1553

    Repair permissions and restart your computer.  If this does not work, zap the pram.  You should now see your external hard drive. 

  • Hello, Honestly I just updated my 4s and my iPad 3 to iOS 6 and when try to press on the Music app or the iTunes app it says "cannot connect to iTunes Store" Could you please help me with this thank you so much, Charbel from Lebanon

    Hello, Honestly I just updated my 4s and my iPad 3 to iOS 6 and when try to press on the Music app or the iTunes app it says "cannot connect to iTunes Store" Could you please help me with this thank you so much, Charbel from Lebanon

    See these previous discussions help.
    App Store Updates (but only Updates)...: Apple Support Communities
    Apps suddenly don't update: Apple Support Communities

  • HT201318 I tried to downgrade my iCloud and when i did it never refunded me can you please help me with this thank you James

    I tried to downgrade my iCloud and when i did it never refunded me can you please help me with this thank you James
    <Personal Information Edited by Host>

    How did you try to downgrade
    (Don't post your telephone number in public places, unless you need more useless phone calls) I will ask for it to be removed.

  • I have unlocked my iphone and when tried to upgrade it, i got an error, so i restored it.But i was not able to activate my iphone 3gs now...it is showing a message like ' sim card not found'..please help me with this regard

    I have unlocked my iphone and when tried to upgrade it, i got an error, so i restored it.But i was not able to activate my iphone 3gs now...it is showing a message like ' sim card not found'..please help me with this regard

    Try popping out the SIM card and turn off the phone.
    Pop in the SIM card once again and turn on the phone, make sure that the SIM card is placed and seated perfectly in the tray!
    Tell me how did you unlock your phone!?

  • Hi, I have a problem with opening files on my desktop. When i double click a file I would lime to open nothing happens. Please help me with this problem :)

    Hi, I have a problem with opening files on my desktop. When i double click a file I would lime to open nothing happens. Please help me with this problem

    hello, this might be a preference in your google search settings. go to google.com/preferences and disable the option to ''Open search results in a new browser window''.

  • HT201487 i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    That's not very intuitive
    Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password.

  • TS3700 I am facing this issues that music stops playing when the display goes...Please help me with this...:)

    I am facing this issues that music stops playing when the display goes...Please help me with this...:)

    Did you see the article linked at the top of this page?
    iPod nano (6th generation): Music stops when display turns off
    B-rock

  • How to change a prospect status to customer in BP,when the prospect turns out to be a potential customer?Please help me with the details.

    How to change a prospect status to customer in BP,when the prospect turns out to be a potential customer?Please help me with the details.
    Moderation: Kindly search before you post

    Dear Ramesh,
    Using Account life cycle we can record the different stages of a BP.
    But at any point of time we can hold one Stage at Business partner.and once we change status Prospect ro Customer. We can't able to see Prospect Status in that BP.
    Ex -
    Stage A- Potentail
    Stage B- Prospect
    Stage C- Customer
    with the help of UI configuration we can define.
    Need your comment,
    Thx
    Karthik

  • Sir Please Help Me With My Homepage. When I Set My Home Page To About:home It Gives An Error Saying Url Not Valid... Please Tell Me how to Fix this!

    Question
    Sir Please Help Me With My Homepage. When I Set My Home Page To About:home It Gives An Error Saying Url Not Valid... Please Tell Me how to Fix this!

    I'm not seeing a screenshot, so could you please try another time to attach one?
    *http://en.wikipedia.org/wiki/Screenshot
    Use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed the maximum file size (1 MB).
    Make sure that you use the location bar and not the (Google) search bar.
    *http://kb.mozillazine.org/Toolbar_customization
    *https://support.mozilla.org/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • Please help me with these java puzzle ?

    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    Please help me with these java puzzle ?
    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    import java.util.*;
    public class MyInt ______ ________ {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    ________ int ___________ {
    MyInt i2 = (MyInt)o;
    return ________;
    }Hints , fill the underlines with below :
    implements
    extends
    Sortable
    Object
    Comparable
    protected
    public
    i = i2.i
    i
    i2.i=i
    compare(MyInt o, MyInt i2)
    compare(Object o, Object i2)
    sort(Object o) sort(MyInt o)
    compareTo(MyInt o)
    compareTo(Object o)

    Dear all,
    My friend send me typical java puzzle aboutNotwithstanding your pathetic protestations typicial
    of all your posts this is NOT a typical java "puzzle"
    but is indeed a typical homework puzzle.
    And it's damn easy if you spent 30 minutes with a
    tutorial.
    DO YOUR OWN HOMEWORK!
    Hey i did it.
    import java.util.*;
    public class MyInt implements Comparable {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    public int compareTo(Object o){
    MyInt i2 = (MyInt)o;
    return i;
    }E:\>javac MyInt.java
    Note: MyInt.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    E:\>java MyInt
    [1, 2]

  • Hi Everyone...Please help me with this query...!

    Please Help me with this doubt as I am unable to understand the logic...behind this code. It's a begineer level code but I need to understand the logic so that I am able to grasp knowledge. Thank you all for being supportive. Please help me.
    //Assume class Demo is inherited from class SuperDemo...in other words class Demo extends SuperDemo
    //Volume is a method declared in SuperDemo which returns an integer value
    //weight is an integer vairable declared in the subclass which is Demo
    class Example
         public static void main(String qw[])
              Demo ob1=new Demo(3,5,7,9);
    //Calling Constructor of Demo which takes in 4 int parameters
              SuperDemo ob2=new SuperDemo();
              int vol;
              vol=ob1.volume();
              System.out.println("Volume of ob1 is " + vol);
              System.out.println("Weight of ob1 is " + ob1.weight);
              System.out.println();
              ob2=ob1;
    }Can someone please make me understand --- how is this possible and why !
    If the above statement is valid then why not this one "System.out.println(ob2.weight);"
    Thanks Thanks Thanks!

    u see the line wherein I am referencing the objectof
    a subclass to the superclass...right? then why we
    can't do System.out.println(ob2.weight)?You need to distinguish two things:
    - the type of the object, which determines with the
    object can do
    - the type of the reference to the object, which
    determines what you see that you can do
    Both don't necessarily have to match. When you use a
    SuperDemo reference (obj2) to access a Demo instance
    (obj1), for all you know, the instance behind obj2 is
    of type SuperDemo. That it's in reality of type Demo
    is unknown to you. And usually, you don't care -
    that's what polymorphism is about.
    So you have a reference obj2 of type SuperDemo.
    SuperDemo objects don't have weight, so you don't see
    it - even though it is there.So from ur explanation wat I understand is - Even though u reference a subclass object to a superclass, u will only be able to access the members which are declared in the superclass thru the same...right
    ?

  • Please help me with portfolio.I am new in graphic design.I need portfolio done immediately soon as possible otherwise my design advisor will not let me register for fall. I need 15 or 10 artworks to show.Please help me

    Please help me with portfolio.I am new in graphic design.I need portfolio done immediately soon as possible otherwise my design advisor will not let me register for fall. I need 15 or 10 artworks to show.Please help me.

    Farooq,
    If you look at the first one, you should be able to align quite easily as follows, View>Smart Guides being your friends:
    1a) ClickDrag the top flower with the Selection Tool (black arrow) so it is clear of the pointy part;
    1b) Click an empty spot on the Artboard to deselect, then ClickDrag the top flower by its bottom Anchor Point (Smart Guides say anchor when you are close enough to grab it) down to snap to the top Anchor Point on the pointy part (Smart Guides say anchor when you are close enough);
    1c) Do the same for the boroom flower.
    If you look at the third one, to get the triangles and the hexagon sized and aligned precisely, you may, creating them with stroke and no fill:
    3a) Click with the Polygon Tool and select a suitable/chosen Radius and 6 Sides, then Object>Transform>Rotate by 30 degrees (or use the Rotate option in the Transform palette), you may Object>Transform>Reset Bounding Box to have it look nicer;
    3b) Click with the Polygon Tool and select the same Radius and 3 sides, then deselect and ClickDrag the top Anchor Point to snap to the top Anchor Point of the hexagon;
    3c) Object>Transform>Rotate by 180 degrees clicking Copy, deselect, and ClickDrag the bottom Anchor Point to snap to the bottomAnchor Point of the hexagon;
    3d) Select all and Ctrl/Cmd+G to Group (for alignment purposes, you will know why if you try without grouping, see below).
    To create full symmetry, you may use circles rather than almost circular ellipses; you may:
    3d) Click with the Ellipse Tool and select a suitable/chosen Width = height;
    3e) Object>Transform>Move a copy vertically by the Height (= Width) twice (or you may Ctrl/Cmd+D to repeat), to get three circles over one another with no gaps;
    3f) Select the topmost and bottommost ones and Object>Transform>Rotate a copy by 120 degrees twice, to have all the seven circles precisley touching one another; you may Group them, but it is not necessary.
    To have everything aligned, just:
    3g) Select everything and click Vertical Align Center and Horizontal Align Center in the Align palette; you may click the pointy group or the circles ojnce more before aligning if you want to keep it in place (that will make it the key object that the other set is aligned to).
    These ways may also help you further.
    Edit: About half an hour after midnight here. High time to attend to other duties, before the sun is up.

  • My MacBook Pro iTunes movie purchase is not showing in iTunes store movie purchases nor does it show on my iPad or Apple TV.  Can someone please help me with a solution?  Thanks.

      First of all, I live in Ho Chi Minh City, Vietnam. Sometimes, I use a VPN to search on the web here. I purchased Toy Story 3 on my MacBook Pro 2011 OS/X - Lion through iTunes.  I initially had trouble downloading it which may be due to being on and off the VPN but after a while it finally downloaded and shows up in my iTunes library on my MacBook. 
      Under my Apple ID account (which is the only Apple ID account I have), I look under purchase history and it shows that I paid for Toy Story which is where I got my Order # from.  But if you go to the iTunes Store then to the Quick Links then click on Purchased, under all my Movies, it does NOT show Toy Story 3 as one of my movies.
      Now when I go to my iPad (3rd gen.), Toy Story 3 does not show up under purchased movies (all or not on my iPad).  It does not show up on my Apple TV as well.  If I want to have Toy Story 3 on my iPad or Apple TV, then it says I have to purchase it again.
      I have searched for help via Apple support communities but so far none of their solutions have worked for me.  I have tried logging off iTunes & App Store on iPad and also shutting down the iPad.  I also made sure that under iTunes Preferences>Store that iTunes in the Clouds purchases is checked. Can someone please help me with this?  Your consideration is greatly appreciated.  Thanks.

    Thanks King_Penguin for taking time to read and reply. 
    I just purchased this movie on Thursday, May 15, so just a few days ago.  I have never had any trouble whatsoever since I have been in Vietnam.  I have downloaded several movies and even music and they have all synced to my respected Apple products except for this purchase. 
    Sorry, I don't quite understand what you mean by studios and different versions.  Could you please explain? 
    I checked my purchased list in my purchase history under my account and there are no hidden items. 

Maybe you are looking for

  • What is the significance of this date & time 0834 14th February 1946

    I have downloaded a number of torrents into my G4 Mac which is linked via the router to this Imac and it's external hard drives. As the G4 has a limited amount of memory on it's HD I dragged the icons for several folder onto the window of an external

  • How to read in JPEG file properties

    Hello AS Community! I am wondering if there is some way to do the following: (1) I have a folder filled with JPEGS with which I can have my SWF access via XML. (2) I would like to create two arrays, one filled with the widths (in pixels) and the othe

  • Getting Drafty

    When I am typing an email and it saves automatically as a draft sometimes it will save it several times with each version having the changes instead of just re-saving to the already saved version. Then when I send the email those multiple drafts don'

  • Code Navigator Issue.

    Hi - I have just installed DW and pasted some web page source code into the main window. The problem is whenever I click any where in the code window I get the code navigator popping up. I tried disabling it as mentioned in the help topic by clicking

  • [OER 11.1.1.6.3] More Search Options feature

    Hi experts, IHAC who is trying to use More Search Options feature. It is able to mark the Filter by Categorizations check box that displays all the categorizations. The problem is that the customer is unable to mark any check box in order to select t