Jeff: Thx. I am only following the homework which I interpret as just calling the add method.
I think I understand the use of the Comparable Interface in MyOwnClass to actually get a value and not a reference, but I am not sure. I am still trying to wrap my head around why this works. Is it simply that String and Integer classes both implement Comparable and any other object added to the LinkedList, ArrayList, ... also needs to implement Comparable? Then it is the "toString" override that is doing all the work here and "compareTo" is implemented only to satisfy the requirement to implement the Interface. Is that it? DaveB ________________________________ From: jghodd <[email protected]> To: [email protected] Sent: Sunday, October 4, 2009 12:18:59 PM Subject: Re: [java programming] Collections Lab 1016 and Xlint: LinkedList.add(E o) returns a boolean value. Are you assigning this value to something or just calling the add method ignoring the return value? myLinkedList.add(myOwnObject); // will generate an unchecked warning boolean b = myLinkedList.add(myOwnObject); // should make the warning go away Jeff On Oct 4, 2009, at 10:57 AM, DaveB wrote: > > Hi All: > > I have 2 questions on adding MyOwnClass to a Linked List or Array > List... > > 1. MyVeryOwnList.add(new MyOwnClass("DaveB")); > > provides output that looks like: > > myownlinkedlist.myowncl...@19821f > > Is there a way to access the methods of that object from the Linked > List, Array list etc? > > Method in MyOwnClass is a simple getName(). > > 2. When I run the program, all is well. > However, when I Clean and Build to get the dist folder and jars, I get > warning to recompile with the -Xlint:unchecked compiler option. After > including this option in the compiler options for the project, the > output prints warnings for each Linked List add like: > > C:\Documents and Settings\Dave\My Documents\MyJava\MyOwnLinkedList\src > \myownlinkedlist\Main.java:33: warning: [unchecked] unchecked call to > add(E) as a member of the raw type java.util.LinkedList > > I have looked this up, but I am unclear as to what is an unchecked > call to add(E) means. > > Can someone help to explain? > > Thx, > DaveB > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
