Putting a class of objects in a Linked List?

Hi,
I copied a program from a book and I want to edit it and put studentRecord class in the Linked List. I've tried to play about with datum, but everything I try doesn't work. Can someone help me out? How could I put studentRecord in the LinkedList?
import java.io.*;
class IO
     static BufferedReader keyboard = new
          BufferedReader(new InputStreamReader(System.in));
     static PrintWriter screen = new PrintWriter(System.out, true);
class studentRecord
     private String name;
     private int IDNumber;
class LinkedList
     class Node
          protected Object datum;
          protected Node link;
          public Node() {}
          public Node(Object item, Node pointer)
               datum = item;
               link = pointer;
     private Node head;
     private Node tail;
     private Node temporary;
     private int nodeCount = 0;
     //constructor
     public LinkedList()
          head = null;
          tail = null;
          temporary = null;
     //method to insert an object into the linked list
     public void insert(Object datum)
          if (head == null) // list empty
               head = new Node(datum, head);
               tail = head;
          else
               temporary = new Node(datum, temporary);
               tail.link = temporary;
               tail = temporary;
               temporary = null;
          nodeCount++;
Full program can be found: http://dil3mma.tripod.com/LinkedList.txt
Thanks in advance.

Hi jverd,
Thanks for replying. I've tried to change the program liked you said but there is 1 error I can't seem to fix(Im sure there are more tho). The error is "cannot resolve symbol" I typed in caps the line it happens on so it's easy to see. Any idea what it could be? Is it cause I'm comparing a String with Object?
import java.io.*;
class IO
     static BufferedReader keyboard = new
          BufferedReader(new InputStreamReader(System.in));
     static PrintWriter screen = new PrintWriter(System.out, true);
class sRecord
     private String name;
     private int IDNumber;
class LinkedList
     class Node
          protected sRecord datum;
          protected Node link;
          public Node() {}
          public Node(sRecord item, Node pointer)
               datum = item;
               link = pointer;
     private Node head;
     private Node tail;
     private Node temporary;
     private int nodeCount = 0;
     //constructor
     public LinkedList()
          head = null;
          tail = null;
          temporary = null;
     //method to insert an object into the linked list
     public void insert(sRecord datum)
          if (head == null) // list empty
               head = new Node(datum, head);
               tail = head;
          else
               temporary = new Node(datum, temporary);
               tail.link = temporary;
               tail = temporary;
               temporary = null;
          nodeCount++;
     //method to delete an object from the linked list
     public boolean delete(Object scrap)
          Node previous = head;
          //for every node in the linked list
          for (Node current = head; current != null; current = current.link)
               //node to be deleted is at the head of the list
               if (current.datum.equals(scrap) && previous == current)
                    head = current.link;
                    if (head == null) tail = null;
                    nodeCount--;
                    return true;
               //node to be deleted is after the first node and before the last
               else if (current.datum.equals(scrap) && (current.link != null))
                    previous.link = current.link;
                    nodeCount--;
                    return true;
               //node to be deleted is at the ned of list
               else if (current.datum.equals(scrap) && (current.link == null))
                    tail = previous;
                    previous.link = null;
                    nodeCount--;
                    return true;
               previous = current;
          return false;
     //method to display the contents of a linked list
     public void displayList()
          Node temporary = head;
          if (head == null)
               IO.screen.println("linked list is empty");
               return;
          while (temporary != null)
               IO.screen.println(temporary.datum);
               temporary = temporary.link;
     //method to return true if the linked list is empty
     public boolean isEmpty()
          return (nodeCount == 0);
     //method to return the number of nodes in the linked list
     public int nodes()
          return nodeCount;
     //method to display a menu to insert data into the linked list
     static private char menu()
          char response = '\u0000';
          IO.screen.println("Do you want to ");
          IO.screen.print("nsert, [D]elete, [L]ist, [E]xit? ");
          IO.screen.flush();
          boolean done=false;
          do
               try
                    String data = IO.keyboard.readLine();
                    response = Character.toUpperCase(data.charAt(0));
                    done = true;
               catch (Exception e)
                    IO.screen.println("Please input a single character I, D, L or E");
          } while (! done);
          return response;
     static public void main(String[] args) throws IOException
          LinkedList list = new LinkedList();
          String datum;
          char choice;
          //get information from menu
          choice = menu();
          for (;;)
               //Menu
               switch (choice)
                    case 'I' :
                         IO.screen.println("type quit to finish input");
                         IO.screen.print("Enter a word ");
                         IO.screen.flush();
                         datum = IO.keyboard.readLine();
                         while (! datum.equals("quit"))
THE ERROR HAPPENS HERE ON THIS LINE          list.insert(datum.name);
                              IO.screen.print("Enter another word");
                              IO.screen.flush();
                              datum = IO.keyboard.readLine();
                         break;
               case 'D' :
                    //if list is empty deletion not possible
                    if (list.isEmpty())
                         IO.screen.println("linked list is empty");
                         break;
                    IO.screen.println("type quit to finish input");
                    IO.screen.print("Delete? ");
                    IO.screen.flush();
                    datum = IO.keyboard.readLine();
                    while (! datum.equals("quit"))
                         if (list.delete(datum))
                              IO.screen.println(datum+" was scrapped!");
                         //if list is empty deletion is not possible
                         if (list.isEmpty())
                              IO.screen.println("linked list is empty");
                              break;
                         IO.screen.print("Delete? ");
                         IO.screen.flush();
                         datum = IO.keyboard.readLine();
                    break;
               case 'L' :
                    list.displayList();
                    IO.screen.println("number of nodes " + list.nodes());
                    break;
               case 'E' : System.exit(0);
          //get information from menu
          choice = menu();

Similar Messages

  • Adding objects to linked list

    Hello everyone. Just working on a little program but have got a little stuck
    So here's one of my classes:
    import java.util.LinkedList;
    import java.util.ListIterator;
    import java.io.*;
    * A program that demonstrates the LinkedList class
    public class BookList
    LinkedList<String> books = new LinkedList<String>();
    ListIterator<String> iterator = books.listIterator();
        public BookList()
        public void DisplayBooks()
            iterator = books.listIterator();
            while (iterator.hasNext())
            System.out.println(iterator.next());
        public void AddBook(String author, String title){
            Book newBook = new Book(author, title);
            books.addFirst(newBook);
    }I want to be able to add a new book object to my linked list but it want compile. Any help would be very appreciated. Thanks in advanced.

    As books is a list of String it can't accept a Book object !
    LinkedList<Book> books = new LinkedList<Book>();

  • Help - can't print linked list object

    Hi all,
    I've written a program that creates an Airplane object. I've added the Airplane object to a linked list. I am trying to test by printing the linked list..but I get the addresses of the airplane object instead of the integer variables that the Airplane object contains. How can I fix this? Here's my output showing what I am talking about:
    Airplane type: 2
    Airplane arrival time: 600
    Airplane cleaning time: 45
    Airplane take-off time: 645
    [Airplane@665753]
    Airplane type: 3
    Airplane arrival time: 1100
    Airplane cleaning time: 60
    Airplane take-off time: 1160
    [Airplane@665753, Airplane@ef22f8]
    Airplane type: 1
    Airplane arrival time: 900
    Airplane cleaning time: 30
    Airplane take-off time: 930
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70]
    Airplane type: 1
    Airplane arrival time: 1100
    Airplane cleaning time: 30
    Airplane take-off time: 1130
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85]
    Airplane type: 3
    Airplane arrival time: 1000
    Airplane cleaning time: 60
    Airplane take-off time: 1060
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80]
    Airplane type: 2
    Airplane arrival time: 900
    Airplane cleaning time: 45
    Airplane take-off time: 945
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80, Airplane@10d81b]
    Airplane type: 2
    Airplane arrival time: 900
    Airplane cleaning time: 45
    Airplane take-off time: 945
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80, Airplane@10d81b, Airplane@dbe178]
    Airplane type: 3
    Airplane arrival time: 1000
    Airplane cleaning time: 60
    Airplane take-off time: 1060
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80, Airplane@10d81b, Airplane@dbe178, Airplane@af9e22]
    Airplane type: 1
    Airplane arrival time: 900
    Airplane cleaning time: 30
    Airplane take-off time: 930
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80, Airplane@10d81b, Airplane@dbe178, Airplane@af9e22, Airplane@b6ece5]
    Airplane type: 1
    Airplane arrival time: 700
    Airplane cleaning time: 30
    Airplane take-off time: 730
    [Airplane@665753, Airplane@ef22f8, Airplane@e0cf70, Airplane@52fe85, Airplane@c40c80, Airplane@10d81b, Airplane@dbe178, Airplane@af9e22, Airplane@b6ece5, Airplane@7ace8d]
    Airplane@665753
    import java.io.*;
    import java.util.*;
    public class AirPortSimulator {
         public static void main(String[] args) {
              LinkedList<Airplane> myEventList = new LinkedList();
                   //for loop to test random number generator for airplane type
              for( int i = 0; i < 10; i++){
                   int parOne = myNumber();
                   System.out.println("Airplane type: " + parOne);
                   int parTwo = myTime();
                   System.out.println("Airplane arrival time: " + parTwo);
                   int parThree = 0;
                   switch(parOne){
                   case 1: parThree = 30;break;
                   case 2: parThree = 45;break;
                   case 3: parThree = 60;break;
                   System.out.println("Airplane cleaning time: " + parThree);
                   int parFour=0;
                   switch(parOne){
                   case 1:     parFour = parTwo + 30;break;
                   case 2: parFour = parTwo + 45;break;
                   case 3: parFour = parTwo + 60;break;
                   System.out.println("Airplane take-off time: " + parFour);
                   System.out.println();
                   Airplane myAirplane = new Airplane(parOne, parTwo, parThree, parFour);
                   myEventList.addLast(myAirplane);
                   System.out.println(myEventList);
                   System.out.println();
         public static int myTime(){
              Random generator = new Random();
              int number = generator.nextInt(16)+1;
              number = number * 100;
              if (number < 600){
                   number = number + 600;
              return number;
         public static int myNumber(){
              Random generator = new Random();
              return generator.nextInt(3)+1;
    }

    I've written a method before that prints all the
    elements of a linked list..but that method onlyheld
    one integer or string...it was a "while (head !=
    null) loop that traversed the list and printed
    "head.info"
    But i'm confused with an object that has 4integers
    inside it...You don't have to write any kind of loop. The
    LinkedList implementation of toString does that for
    you. All you have to do is write a toString for
    Airplane that prints whatever you feel is important
    for a single Airplane object.
    But note that since the list uses commas to separate
    entries, your toString method will be clearer if you
    can write it in such a way that it doesn't use
    commas, or so that you can see where the output
    begins and ends. For example, maybe you can wrap the
    output with curly brackets.Thanks, I just had to understand what the toString method was and then how to override it. This works well:
    Thank you for pointing me in the right direction.
    aiki985
    public String toString(){
                  return "{" + airplaneType + ", " + arrivalTime + ", " +
                                  waitingTime + ", " + departureTime + "}";
              } // end toString method

  • After Delete in Linked list...unable to display the linked list

    Hi...i know that there is an implementation of the class Linked Link but i am required to show how the linked list works in this case for my project...please help...
    Yes..I tried to delete some objects in a linked list but after that i am not able to display the objects that were already in the linked list properly and instead it throws an NullPointerException.
    Below shows the relevant coding for deleting and listing the linked list...
    public Node remove(Comparator comparer) throws Exception {
         boolean found = false;
         Node prevnode = head;          //the node before the nextnode
         Node deletedNode = null;     //node deleted...
         //get next node and apply removal criteria
         for(Node nextnode = head.getNextNode(); nextnode != null; nextnode = nextnode.getNextNode()) {
              if(comparer.equals(nextnode)) {
                   found = true;
                   //remove the next node from the list and return it
                   prevnode.setNextNode(nextnode.getNextNode());
                   nextnode.setNextNode(null);
                   deletedNode = nextnode;
                   count = count - 1;
                   break;
         if (found) return deletedNode;
         else throw new Exception ("Not found !!!");
    public Object[] list() {
         //code to gather information into object array
         Node node;
         Object[] nodes = new Object[count];
         node = head.getNextNode();
         for (int i=0; i<count; i++) {
              nodes[i] = node.getInformation();  // this is the line that cause runtime error after deleting...but before deleting, it works without problem.
              node = node.getNextNode();
         return nodes;
    }Please help me in figuring out what went wrong with that line...so far i really can't see any problem with it but it still throws a NullPointerException
    Thanks

    OK -- I've had a cup and my systems are coming back on line...
    The problem looks to be the way that you are handling the pointer to the previous node in your deletion code. Essentially, that is not getting incremented along with the nextNode -- it is always pointing to head. So when you find the node to delete then the line
       prevnode.setNextNode(nextnode.getNextNode());will set the nextNode for head to be null in certain situations (like if you are removing the tail, for instance).
    Then when you try to print out the list, the first call you make is
    node = head.getNextNode();Which has been set to null, so you get an NPE when you try to access the information.
    Nothing like my favorite alkaloid to help things along on a Monday morning...
    - N

  • Read Hashmap into a Linked List

    Hi,
    I have a hashmap containing objects; I want to put those objects into a linked list.
    Where do I start? I haven't the foggiest idea....
    I suppose I have to iterate through the hashmap and extract the objects and then put them into a linked list.
    Does anyone know of a good tutorial for that kind of thing?
    Cheers,
    Didhe

    I'm no expert on this (far from it), but on looking
    at the HashMap and LinkedList API's, there may be
    something easy available to you.Yes, another URL to bookmark:
    http://java.sun.com/javase/6/docs/api/

  • Elements overwrites each others in Linked List

    hello, my problem is mentioned as the subject.
    i'm trying to add the same object into a linked list each time with different values, however it doesn't work and eventually all objects stored in the linked list become identical.
    here's the sample code.
    public class Object1
         private String s = null;     
         public Object1(){}
         public void setS(String s){this.s = s;}
         public String getS(){return s;}
    import java.io.*;
    import java.util.List;
    import java.util.LinkedList;
    import java.util.Collections;
    public class Test
         public static void main(String[] args)
              List ll = Collections.synchronizedList(new LinkedList());
              Object1 obj1 = new Object1();
              obj1.setS("111111");          
              ll.add(obj1);
              for (int i=0; i<ll.size(); i++)
                   Object1 obj2 = (Object1)ll.get(i);
                   System.out.println(">>>>>before:: " + obj2.getS() + "\n");
              obj1.setS("2222222");
              ll.add(obj1);
              for (int i=0; i<ll.size(); i++)
                   Object1 obj2 = (Object1)ll.get(i);
                   System.out.println(">>>>>after:: " + obj2.getS());          
    and the result looks like this:
    before:: 111111
    after:: 2222222
    after:: 2222222what i really want is something like this instead:
    before:: 111111
    after:: 111111
    after:: 2222222could any one please help
    thanks in advance
    cedricc

    You need to understand the distinction between references and objects. You're not storing objects in the linked list, but references. All of these references point to the same object. You need to create a new object each time through the loop.

  • Need help with linked lists.

    I have a school assignment to make a linked list with a linked list.
    The first basic is to make a list of people, and link them together in a linked list. So far, so good.
    The problem comes when I'm going to make linked lists in each of these objects that include the relationships between the people in it.
    So If I have 10 peolpe in a list, person 1 might know person 3, 4 and 8. They will all know person 1 back of course. My problem is that it isn't just one group of friends, person 3 might not know person 4 and 8, but maybe he knows person 10. So all need "their own" list.
    Therefor I can't see how I'm supposed to use linked lists for them, as I can't just link them togeter with e.g. "Person nextFriend;" The text says specifically to use linked lists. Well, I'm stuck.
    Edited by: Skruf on Jan 27, 2009 3:22 PM

    Skruf wrote:
    I know it doesn't matter what the objects represent, I just needed a way to explain.
    But a linked list is basically just a redirect to the next in the list, right?No, a linked list is a particular implementation of a list.
    Then I can't see how it's possible to make individual friend lists.No clue what problem you're having.
    People with links
    null - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - nullThat means nothing.
    I can't see how that can be used to make independent links. Do they mean that I'm support to stort it in arrays or something then?
    The person list, is (as you can see in my "illustration") only a "next" and "previous" person, so I can't use that way to link the friends together. nextFriend and lastFriend obviously doesn't work.
    That's my problemLike I said: A Person object contains a linked list. In that linked list you put references to that Person's friends.

  • Link List problems

    The code is supposed to go and get names from objects in a linked list, then sort them alphabeticaly, then put them into a new list.
    getNameAtCurrent returns a String, enqueue puts the ListNodes into a new LinkedList. showList prints out the entire list.
              int size = linker.length( );
              linker.resetIteration( );
              String[] nameSort = new String[size];
              for(int i = 0; i < size; i++)
                   nameSort[i] = linker.getNameAtCurrent( );
              for(int i = 0; i < size-1; i++)
                   String a = nameSort;
                   String b = nameSort[i+1];
                   if(a.compareTo(b) > 0)
                        String tempName = nameSort[i];
                        nameSort[i] = nameSort[i+1];
                        nameSort[i+1] = tempName;
                   else if(a.compareTo(b) == 0)
              LinkedListWithIterator nameSorted = new LinkedListWithIterator();
              for(int j = 0; j > size-1; j++)
                   nameSorted.enqueue(linker.Find(nameSort[j]));
              nameSorted.showList();

    public void enqueue(ListNode data) //Enqueues data
              if (head == null)
                   head = current = data;
              else
                   current = (current.link = data);
        }I guess this might be the main probelm with the entire bit of code. The list has 4 strings stored in it, and I guess I'm trying to find the ListNode that the sorted string is stored in and put those into a new LinkedList in the order that the sorted names were in.
    I have no clue if this works at all, but its just supposed to find the node that had the string in it and copy it to a new LinkedList

  • Is it possible to implement or represent a Linked List in LabVIEW?

    Linked lists are a useful way to store and retrieve data and I am wondering if it is possible to create or acheive the same objective of a linked list in LabVIEW.

    A linked list is a collection of nodes, each node has data and a link (or pointer) to the location of the next node.
    In LabVIEW we can create a collection of nodes as an array of clusters. One element of the cluster will be our data, and the other will be an integer pointer to the location in the array, of our next node.
    In, fact you can go crazy and represent a LabVIEW Hierarchy in a similar fasion (a tree structure). Now, each cluster will have data about the VI (its Name, attributes, etc), an array of integers that point the the locations of calling VIs, and an array of integers that point the the locations of subVIs.
    You will, of course also need some tools for sorting your lists/trees and performing useful operations... lot's of fun!
    Good luck
    Jim

  • Problem with Linked List

    i have make a database with linked list for a School student counselor.
    The to be store is
    student name, ID, Counseling Date, Progress
    In there there will be record for a student and the Date and progress has to be stored for 4-weeks as the counseling is on weekly basis. These data items will be multivalued(what u say in Databases) how i can store this repetitive data in linked list for one student.

    By capsulating the data in objects and adding the objects to a linked list.

  • Putting a Class Object into a Vector

    HI all
    I need to put a class object into another classes vector, then be able to read it and retrieve data.
    I can put the object into the vector but all i seem to be able to retrieve is data like Account@2343c2.
    Is this some sort of tag? How do i get to the data?
    thankz
    joey

    That's what you get when you print an object which does not have its own toString() method to do anything different - it picks up the Object class's toString method instead. For example:
    System.out.println(new Object());It sounds like you're doing something like this:
    Vector v = new Vector();
    v.add(new Account(42));If you were to do the following, you would see that sort of output:
    System.out.println(v.get(0));The appropriate way to do this would be something like the following:
       // Use a List reference instead of a Vector reference, and create
       // an ArrayList object in preference to a Vector object
       List list = new ArrayList();
       list.add(new Account(42));
       // Iterate through the list of accounts - use an
       // iterator because this prevents off-by-one errors
       // that arise with direct indexing.
       Iterator i = list.iterator();
       while(i.hasNext()) {
          // Cast the reference returned by the iterator from
          // Object to Account so that we can call account-specific
          // methods.
          Account current = (Account)i.next();
          // Call the method specific to the Account class (getBalance
          // is just an example that I made up).
          System.out.println(current.getBalance());
       }

  • [svn:bz-4.0.0_fixes] 20451: backporting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20451
    Revision: 20451
    Author:   [email protected]
    Date:     2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
    Log Message:
    backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • [svn:bz-3.x] 20443: back porting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20443
    Revision: 20443
    Author:   [email protected]
    Date:     2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
    Log Message:
    back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java

  • How to use methods when objects stored in a linked list?

    Hi friend:
    I stored a series of objects of certain class inside a linked list. When I get one of them out of the list, I want to use the instance method associated with this object. However, the complier only allow me to treat this object as general object, ( of Object Class), as a result I can't use instance methods which are associated with this object. Can someone tell me how to use the methods associated with the objects which are stored inside a linked list?
    Here is my code:
    import java.util.*;
    public class QueueW
         LinkedList qList;
         public QueueW(Collection s) //Constructor of QuequW Class
              qList = new LinkedList(s); //Declare an object linked list
         public void addWaiting(WaitingList w)
         boolean result = qList.isEmpty(); //true if list contains no elements
              if (result)
              qList.addFirst(w);
              else
              qList.add(w);
         public int printCid()
         Object d = qList.getFirst(); // the complier doesn't allow me to treat d as a object of waitingList class
              int n = d.getCid(); // so I use "Object d"
         return n; // yet object can't use getCid() method, so I got error in "int n = d.getCid()"
         public void removeWaiting(WaitingList w)
         qList.removeFirst();
    class WaitingList
    int cusmNo;
    String cusmName;
    int cid;
    private static int id_count = 0;
         /* constructor */
         public WaitingList(int c, String cN)
         cusmNo = c;
         cusmName = cN;
         cid = ++id_count;
         public int getCid() //this is the method I want to use
         return cid;

    Use casting. In other words, cat the object taken from the collection to the correct type and call your method.
       HashMap map = /* ... */;
       map.put(someKey, myObject);
       ((MyClass)(map.get(someKey)).myMethod();Chuck

  • Convert an embedded smart object to a linked smart object

    Hey guys,
    love the new "linked smart object" functionality. However, I can not figure out how I can convert (or export) an existing embedded smart object to a linked smart object.
    I have a huge photoshop file with several embedded smart objects that I would like to break down into a lightweigt photoshop with with links to the varios smart object photoshop files.
    Is there any way to do this?
    Thanks,
    Philipp

    Thanks a lot guys.
    I am just now putting a document together with linked smart objects and I'm noticing that the file size of the PSD file still increases quite a bit. I thought the hole point of this was to have lightweigh psd files?
    I currently have 11 1920x1080 linked smart object files in the PSD and the file size is already at 140MB. Any ideas why this is happening?

Maybe you are looking for