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>();

Similar Messages

  • Problem with Queue and linked list

    Hi... i've got an assignment it start like this.
    You are required to write a complete console program in java includin main() to demonstrate the following:
    Data Structure: Queue, Priority Queue
    Object Involved: Linked-List, PrintJob
    Operations Involved:
    1. insert
    2. remove
    3. reset
    4. search
    Dats all... I've been given this much information... Can any1 try to help me please... How to make a start??? And wat does the print job means???
    Can any1 tell me wat am supposed to do...

    Hi,
    Why don't you start your demo like this?
    import java.io.IOException;
    public class Demo {
         public Demo() {
         public void startDemo() throws IOException {
              do {
                   System.out.println("String Console Demo ");
                   System.out.println("\t" + "1. Queue Demo");
                   System.out.println("\t" + "2. PriorityQueue Demo");
                   System.out.println("\t" + "3. LinkedList Demo");
                   System.out.println("\t" + "4. PrintJob Demo");
                   System.out.println("Please choose one option");
                   choice = (char) System.in.read();
                   showDemo(choice);
              } while (choice < '1' || choice > '4');
         public void showDemo(char ch) {
              switch (ch) {
              case '1':
                   System.out.println("You have chosen Queue Demo ");
                   showOperations();
                   break;
              case '2':
                   System.out.println("You have chosen Priority Queue Demo ");
                   showOperations();
                   break;
              case '3':
                   System.out.println("You have chosen LinkedList Demo ");
                   showOperations();
                   break;
              case '4':
                   System.out.println("You have chosen Print Job Demo ");
                   showOperations();
                   break;
         private void showOperations() {
              System.out.println("Please choose any operations ");
              System.out.println("\t" + "1. Insert ");
              System.out.println("\t" + "2. Remove ");
              System.out.println("\t" + "3. Reset ");
              System.out.println("\t" + "4. search ");
         public static void main(String[] args) throws IOException {
              Demo demo = new Demo();
              demo.startDemo();
         private char choice;
    Write a separate classes for the data structures show the initial elements and call the methods based on the operations then show the result.
    Thanks

  • Linked List

    Hello
    I got a problem trying to store arrays in a linked list. i need to store 3 numbers in the array(eg a[0], a[1], a[2]) in a link list and another 3 in another and so on. (dnt have to use arrays but i used it to store the 3 number in one linked list)
    when i use arrays to store em it says cants store int cos my links list stores objects! i cant convert the numbers to object cos then i need to search for the particular set of numbers from the link list.
    if some one could help me by explaing wat i could do i will be gratefull
    thanks!!!

    Yes, as danperkins suggests you can insert groups of three int[] into your list ...and then as your search through the list, pull each group of three ints back out of each list node and analyze them on the spot to see if they are equal.
    What I was suggesting is to encapsulate your three ints into a class that becomes an entity called, say ...ThreeInts. Then, you could add the functionality inside this object to determine if it was equal to another object of the same type. Same thing as danperkins suggestion, except one requires external routines to process each node and the other (mine) uses an object that knows how to process itself.
    This is a fundamental facet of OOP programming ...representing data in objects that know how to store their values ...know how to express themselves ...know how to order and compare themselves ...etc, etc, etc.
    The way I see it, I have given you the structures required to complete your task ...you just have to operate on them and incorporate them into your code. If you don't see how to do this, then I don't really know what else to suggest ...sorry.
    semi - psuedocode created from what you have so far might be as follows.
    // Insert ThreeInts objects into linked list...
    // Where array is original array of 120 ints...
    for (int k=0, k<array.length; k++) {
      if( (k%3)==0 && k!=0 ) {
        list.add(new ThreeInts(array[k-2],array[k-1],array[k]);
    // Search for specific ThreeInts objects in linked list...
    // i.e. "find an object in the list equal to the object ThreeInts(3,5,8)"
    ThreeInts found = searchList( new ThreeInts(3,5,8) );Basically, the ThreeInts object is a class that knows how to hold three integers ...knows how to give these three integers back to you ...and most importantly knows how to compare itself to another ThreeInts object and say "yes, I am the same" ...or "No, I am not the same". That is what MyCuteLittleClass will do ...you just have to change its name to ThreeInts. Beyond this, I don't know what else to say.

  • 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

  • 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

  • Changing data in a linked list object.

    hi,
    i'm still pretty new to java, so bear with me if i am making stupid mistakes, heh.
    i'm having trouble with changing data in an object stored in a singly-linked list. i've created a class that will store polynomials in sorted order (descending) in a singly-linked list. each linked list is one polynomial, and each node references to a polynomial object that stores two ints: the coefficient and the exponent of that term.
    i'm having trouble when it comes to 'collecting like terms,' though. here's a rough skeleton of my code:
    public class Polynomial
    private LinkedList polynoList;
    private LinkedListItr Itr;
    private int coeff;
    private int exponent;
    public Polynomial()
    zeroPolynomial();
    } // this constructor sets up an empty linked list
    public Polynomial( int c, int e )
    coeff = c;
    exponent = e;
    } // this creates a Polynomial object storing the two ints
    public void zeroPolynomial()
    polynoList = new LinkedList();
    theItr = polynoList.zeroth();
    } // this method creates the empty linked list and sets the
    //iterator on the zeroth node.
    //various other methods are here, not relevant to my post
    //this next method is the one i am having trouble with.
    //it takes two ints as parameters, the coefficient
    //and the exponent.
    public void insertTerm( int c, int e )
    //...i have a few if/then statements here
    //so that the terms can be inserted in descending order.
    LinkedListItr tester = polynoList.first();
    //the 'tester' iterator is set on the first node
    //this following if statement retrieves the exponent
    //in the current node by casting the information
    //retrieved from the LinkedList retrieve() method
    //into Polynomial, then compares it to the current
    //exponent. if they are equal, i want to add the
    //coefficients.
    if( e == ((Polynomial)tester.retrieve()).getExp() )
    this.coeff = ((Polynomial)tester.retrieve()).getCoeff() + c;
    //a main method goes here wherein the user can insert
    //terms, print the polynomial, etc.
    }//end Polynomial class
    can anyone help me out? the code i'm using compiles correctly, but it does not change the value of the current coeff variable as i'd like to think it should. any input would be GREATLY appreciated, thanks!

    hey,
    thanks for the reply...
    i am sure that ((Polynomial)tester.retrieve()).getExp() will return an int equal to 'e.' i tried this:
    System.out.println("e="+e);
    System.out.println((Polynomial)tester.retrieve()).getExp());
    if( e == ((Polynomial)tester.retrieve()).getExp() ){
    this.coeff = ((Polynomial)tester.retrieve()).getCoeff() + c;
    System.out.println( "this.coeff = " + this.coeff );
    with that, the output showed that e and the getExp() output were the same. it also showed (as output) that this.coeff did change in value, but when i tried this:
    System.out.println( ((Polynomial)tester.retrieve()).getCoeff() )
    to check if the value changed within the object, it didn't. this.coeff changed, but the actual coeff variable in the object didn't.
    any ideas?

  • 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();

  • Concatination of 2 linked list objects of characters

    Pleas help me to solve the following problem by using Java.
    Problem: Write a program that concatenates two linked list objects of characters. The program should include method concatenate, which takes references to both list objects as arguments and concatenates the second list to the first list.
    Thanking u,
    Ripon

    This assumes that your class is 'ListConcatenate' and that you have set up your two link-lists.
         public void concatenate( ListConcatenate l1, ListConcatenate l2)
              if ( l1.isEmpty1() || l2.isEmpty2() )
                   System.out.printf( "Empty %s or Empty %s\n", name1,name2 );
                   return;
              System.out.printf( "%s concatenated with %s is: ", name1,name2 );
              NodeOne current1 = l1.firstNode1;
              NodeTwo current2 = l2.firstNode2;
              while (current1 != null )
                   System.out.printf( "%s ", current1.data1.toString() + current2.data2.toString() );
                   current1 = current1.nextNode1;
                   current2 = current2.nextNode2;
              }

  • Object linked list

    Hi am trying to create a linked list out of an object i have called ClassID.
    I have a Link class (that creates a node correct?):
    import java.io.*;
    public class Link
         public ClassID id;
        public Link next;
         public Link(ClassID inID)
              this(inID, null);
        public Link(ClassID inID, Link next)
            id = inID;
            next = next;;
         public void displayLink() // display ourself
              id.toString();
    } // end class LinkIf it does create node then I have a class called LinkList with the following insert method:
    private Link first; // ref to first link on list
    // insert at start of list
         public void insertFirst(Link id)
         { // make new link
              Link newLink = new Link(id);
              newLink.next = first; // newLink --> old first
              first = newLink; // first --> newLinkBut it doesnt seem to be working, could someone help me.
    Thanks
    Phil
    Edited by: The_One on Sep 13, 2008 1:49 AM

    I dont think its doing it properly. Iv tried goign through it but cant find the problem. Might be a problem with displaylist
    Let me paste all my classes:
    LINK METHOD:
    import java.io.*;
    public class Link
         public ClassID id;
        public Link next;
         public Link(ClassID inID)
              this(inID, null);
        public Link(ClassID inID, Link next)
            id = inID;
            next = next;;
         public void displayLink() // display ourself
              id.toString();
    } // end class LinkLINKLIST METHOD:
    class LinkList
         private Link first; // ref to first link on list
         public LinkList() // constructor
              first = new Link(null); // no items on list yet
         public boolean isEmpty() // true if list is empty
              return (first==null);
         // insert at start of list
         public void insertFirst(ClassID id)
         { // make new link
              Link newLink = new Link(id);
              newLink.next = first; // newLink --> old first
              first = newLink; // first --> newLink
    public void displayList()
              System.out.print("List (first-->last): ");
              Link current = first; // start at beginning of list
              while(current != null) // until end of list,
                   current.displayLink(); // print data
                   current = current.next; // move to next link
              System.out.println("");
    ................. SOME MORE METHODS..........MAIN METHOD:
    import java.io.*;
    public class SortListApp
        public static void main(String[] args)
         BufferedReader inputStream = null;
         LinkList list = new LinkList();
         try
              inputStream = new BufferedReader(new FileReader("data.txt"));
               String inName;
              int inIDNum;
              int inACNum;
              long inTime;
              int inTransmode;
              //while ((inName = (inputStream.readLine()) ) != null)
                   inName = inputStream.readLine();
                   inIDNum = Integer.parseInt(inputStream.readLine());
                   inACNum = Integer.parseInt(inputStream.readLine());
                   inTime = Long.parseLong(inputStream.readLine());
                   inTransmode = Integer.parseInt(inputStream.readLine());
                   list.insertFirst(new ClassID(inName, inIDNum, inACNum, inTime, inTransmode));                    
              list.displayList();
              //System.out.println("Printed to file");
              //list.sort();
              inputStream.close();
         catch (IOException error)
              System.out.println("Error in file");
    }Edited by: The_One on Sep 13, 2008 2:41 AM

  • [svn:bz-trunk] 18926: bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError

    Revision: 18926
    Revision: 18926
    Author:   [email protected]
    Date:     2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
    Log Message:
    bug fix BLZ-570 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
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java

  • [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

  • Adding objects to list

    Hi,
    I am new java. I have a probelm adding objects to list. This is the following code.
    class Test{
    List <>dataList = new ArrayList<>();
    public List<A> getAList(){
    dataList.add(new A());
    return dataList ;
    public List<B> getBList(){
    dataList.add(new B());
    return dataList;
    }In the above code what I will pass<parameterized data> to the dataList decalred as member variable?

    bhanu wrote:
    nothing common for A and B. Both A and B are different pojos. but we can tell A and B extends from Object.I tried like that
    way. But it is not working. <? extends from Object>.Both two methods have to be in the same classYou do in that case have a bad design. Why is the same list used for both. It can't be type safe so you need to cast and the user of the list might get classcast exceptions during iteration.
    Kaj

  • Linked List, Stacks and Other Data Structures in Objective-C 2.0

    I've checked a little throughout documentation that Apple provides for the different frameworks in order to determine if there were ready-made classes for data structures such as linked lists, stacks and so forth but there don't appear to be any available? Is this correct?

    NSArray and NSDictionary are the multi-purpose built-in aggregate types. If you need something else then you can use STL or roll your own.

  • Help needed in linked lists...

    I have been working on this computer assignment lately but I still don't understand linked lists yet..I did an assignment on array based implementation and now I am supposed to do the same thing in linked list implementation..
    I need help on how to change this into a linked list implementation..any help would be appreciated. Thank you..below is the code for the array based implementation..the only thing that needs change here is after where is says Array-based implementation of the ADT list.
    public class ListArrayBasedDriver {
      public static void main(String [] args) {
        ListArrayBased myGroceryList = new ListArrayBased();
        myGroceryList.add(1,"milk");
        myGroceryList.add(2,"eggs");
        myGroceryList.add(3,"butter");
        myGroceryList.add(4,"pecans");
        myGroceryList.add(5,"apples");
        myGroceryList.add(6,"bread");
        myGroceryList.add(7,"chicken");
        myGroceryList.add(8,"rice");
        myGroceryList.add(9,"red beans");
        myGroceryList.add(10,"sausage");
        myGroceryList.add(11,"flour");
        printList(myGroceryList); //print out original List
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("adding juice for 5th item...");
        myGroceryList.add (5, (Object) "juice");  //add juice
        System.out.println("item 5 is: " + myGroceryList.get(5)); //get position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("removing juice...");
        myGroceryList.remove (5); //remove item at position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
      public static void printList(ListArrayBased myList)
            //method prints a list, numbering the values,  e.g, "1.  milk" .... "5.  juice".... etc.
            int i;
            for(i=1; i <= myList.size(); i++)
                String tempString = new String((String)myList.get(i));
                System.out.println(i+" "+ tempString);
    // Array-based implementation of the ADT list.
    class ListArrayBased {
        private static final int MAX_LIST = 50;
        private Object items[];  // an array of list items
        private int numItems;  // number of items in list
        public ListArrayBased()
        // creates an empty list
             items = new Object[MAX_LIST];
             numItems = 0;
        }  // end default constructor
        public boolean isEmpty()
          return (numItems == 0);
        } // end isEmpty
        public int size()
           return numItems;
        }  // end size
        public void removeAll()
          // Creates a new array; marks old array for
          // garbage collection.
          items = new Object[MAX_LIST];
          numItems = 0;
        } // end removeAll
        public void add(int index, Object item) throws  ListIndexOutOfBoundsException
          if (numItems > MAX_LIST)
            throw new ListException("ListException on add");
        }  // end if
          if (index >= 1 && index <= numItems+1)
            // make room for new element by shifting all items at
            // positions >= index toward the end of the
            // list (no shift if index == numItems+1)
            for (int pos = numItems; pos >= index; pos--) {
              items[translate(pos+1)] = items[translate(pos)];
          } // end for
          // insert new item
          items[translate(index)] = item;
          numItems++;
          else
          {  // index out of range
            throw new ListIndexOutOfBoundsException(
             "ListIndexOutOfBoundsException on add");
          }  // end if
        } //end add
        public Object get(int index) throws ListIndexOutOfBoundsException
          if (index >= 1 && index <= numItems)
            return items[translate(index)];
          else 
          {  // index out of range
            throw new ListIndexOutOfBoundsException(
              "ListIndexOutOfBoundsException on get");
          }  // end if
        } // end get
        public void remove(int index) throws ListIndexOutOfBoundsException
          if (index >= 1 && index <= numItems)
            // delete item by shifting all items at
            // positions > index toward the beginning of the list
            // (no shift if index == size)
                for (int pos = index+1; pos <= size(); pos++) {
                    items[translate(pos-1)] = items[translate(pos)];
          }  // end for
          numItems--;    
          else
          {  // index out of range
            throw new ListIndexOutOfBoundsException("ListIndexOutOfBoundsException on remove");
          }  // end if
        } // end remove
        private int translate(int position) {
        return position - 1;
       } // end translate
    }  // end ListArrayBased
    class ListException extends RuntimeException
      public ListException(String s)
        super(s);
      }  // end constructor
    }  // end ListException
    class ListIndexOutOfBoundsException
                extends IndexOutOfBoundsException {
      public ListIndexOutOfBoundsException(String s) {
        super(s);
      }  // end constructor
    }  // end ListIndexOutOfBoundsException

    Could someone check for me if this will work and if it doesn't what I need to do to make it work..Thanks...
    public class ListArrayBasedDriver {
      public static void main(String [] args) {
        ListArrayBased myGroceryList = new ListArrayBased();
        myGroceryList.add(1,"milk");
        myGroceryList.add(2,"eggs");
        myGroceryList.add(3,"butter");
        myGroceryList.add(4,"pecans");
        myGroceryList.add(5,"apples");
        myGroceryList.add(6,"bread");
        myGroceryList.add(7,"chicken");
        myGroceryList.add(8,"rice");
        myGroceryList.add(9,"red beans");
        myGroceryList.add(10,"sausage");
        myGroceryList.add(11,"flour");
        printList(myGroceryList); //print out original List
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("adding juice for 5th item...");
        myGroceryList.add (5, (Object) "juice");  //add juice
        System.out.println("item 5 is: " + myGroceryList.get(5)); //get position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
        System.out.println("removing juice...");
        myGroceryList.remove (5); //remove item at position 5
        printList(myGroceryList);
        System.out.print("numItems is now: " + myGroceryList.size() + "\n");
      public static void printList(ListArrayBased myList)
            //method prints a list, numbering the values,  e.g, "1.  milk" .... "5.  juice".... etc.
            int i;
            for(i=1; i <= myList.size(); i++)
                String tempString = new String((String)myList.get(i));
                System.out.println(i+" "+ tempString);
    // Linked List-based implementation of the ADT list.
    class ListNode
         //class to represent one node in a list
         class ListNode
              //package access members; List can access these directly
              Object data;
              ListNode nextNode;
              //contructor creates a ListNode that refers to object
              ListNode( Object object)
                   this( object, null );
              } //end ListNode one-argument constructor
              //constructor creates ListNode that refers to
              // Object and to the next ListNode
              ListNode ( Object object, ListNode node)
                   data = object;
                   nextNode = node;
              // end ListNode two-argument contructor
              //return reference to data in node
              Object getObject()
                   return data; // return Object in this mode
              //return reference to next node in list
              ListNode getNext()
                   return nextNode; // get next node
              } // end method getNext
    } //end class ListNode
    //class List Definition
    public class List
         private ListNode firstNode;
         private ListNode lastNode;
         private String name; // string like " list " used in printing
         //contructor creates empty List with " list " as the name
         public List()
              this(" list ");
         } //end List no-arguement constructor
    //contructor creates an empty list with a name
    public List( String listName )
         name = listname;
         firstNode = lastNode = null;
    } //end List no-arguement contructor
    //insert Object at front of List
    public void insertAtFront ( object insertItem )
         if ( isEmpty() ) //firstNode and lastNode refer to same object
              firstNode = lastNode = newListNode( insertItem );
         else // firstNode refers to new node
              firstNode = new ListNode ( insertItem, firstNode );
    } // end method insertAtFront
    // insert Object at end of List
    public void insert AtBack ( Object insertItem )
         if ( isEmpty() ) //firstNode and lastNode refer to same object
              firstNode = new ListNode ( insertItem );
         else // firstNode refers to new node
         firstNode = new ListNode (insertItem, firstNode );
    } // end method insertAtFront
    // insert Object at end of List
    public void insertAtBack ( Object insertItem )
         if ( isEmpty() ) //firstNode and LastNode refer to same Object
              firstNode = lastNode = new ListNode ( insertItem );
         else // lastNode = lastNode.nextNode = new ListNode ( insertItem );
    } // end method insertAtBack
    //remove first node from List
    public Object removeFromFront() throws EmptyListException
         if( isEmpty() ) //throw exception if list is empty
         throw new EmptyListException( name );
         object removedItem = firstNode.data; //retrieve data being removed
    // update references firstNode and lastNode
    if (firstNode == lastNode )
         firstNode =lastNode = null;
    else
         firstNode = firstNode.nextNode;
         return removedItem; // return removed node data
    } //end method removeFromFront
    //remove last node from List
    Public Object removeFromBack() throws EmptyListException
         If ( isEmpty() ) // throw exception if list is empty
              throw new EmptyListException( name );
         Object removedItem = lastNode.data; // retrieve data being removed
         // update references firstNode and lastNode
         If ( firstNode == lastNode )
              firstNode = lastNode = null;
         else // locate new last node
              ListNode current = firstNode;
              // loop while current node does not refer to lastNode
              while ( current.nextNode != lastNode )
                   current = current.nextNode;
              lastNode = current; // current is new lastNode
              current.nextNode = null;
         } // end else
         return removedItem; // return removed node data
    } // end method removeFromBack
    // determine whether list is empty
    public boolean isEmpty()
         return firstNode == null; // return true if list is empty
    }     // end method isEmpty
    //output List contents
    public void print()
         if (isEmpty() )
              System.out.printf(�Empty %s\n�, name );
              return;
         System.out.printf(�The %s is: �, name );
         ListNode current = firstNode;
         //while (current != null )
              System.out,printf(�%s �, current.data );
              current = current.nextNode;
         } //end while
         System.out.println( �\n� );
    } //end method print
    } end class List

Maybe you are looking for