Okay, I have been programming a C++ for a while, so I am little befuddled trying to figure this one out. After assigning an instance of a class to a container, how to you display all of the instance variables. All I can figure out is how to display the reference, which is what happens when you assign an object instance to a container. Any help would be much appreciated; here's the code:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mycollectionproject; import java.util.Set; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.ArrayList; import java.util.Iterator; import javax.swing.JOptionPane; /** * * @author Phyxashun */ public class Main { /** * @param args the command line arguments */ @SuppressWarnings("unchecked") public static void main(String[] args) { Set s = new HashSet(); String msg = new String(); s.add(new String ("Dusty")); s.add(new String ("Phyxashun")); s.add(new MyOwnClass("Dusty", 29)); s.add(new MyOwnClass("Old Man", 54)); s.add(new Integer (5)); s.add(new Integer (55)); s.add(new Integer (555)); for (Iterator iterator = s.iterator(); iterator.hasNext(); ) { msg += "HashSet: " + iterator.next() + "\n"; } JOptionPane.showMessageDialog(null, msg, "HashSet", 1); s = new LinkedHashSet(s); msg = new String(); for (Iterator iterator = s.iterator(); iterator.hasNext(); ) { msg += "LinkedHashSet: " + iterator.next() + "\n"; } JOptionPane.showMessageDialog(null, msg, "LinkedHashSet", 1); ArrayList aList = new ArrayList(s); msg = new String(); for (Iterator iterator = aList.iterator(); iterator.hasNext (); ) { msg += "ArrayList: " + iterator.next() + "\n"; } JOptionPane.showMessageDialog(null, msg, "ArrayList", 1); } } Cheers! Dusty --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---