Saving linked list into oracle

hi, i want to store a linked list in sql, and it should be like that it should grow itself , if i want to add some elements in future,
i know i have to use jdbc, but if i can get some kind of example for that , it will be quite easier then.....any idea plzz

Have tables like this?
LIST table:
LIST_ID <PK>
...any other fields you wish...
LIST_ELEMENT table:
LIST_ID <PK> <FK>
LIST_INDEX <PK>
ELEMENT_DATA
...

Similar Messages

  • How to implement a linked list in oracle ?

    HI All
    I want to know if there a way to implement a linked list in oracle ?
    Thanks in Advanced
    Naama

    A linked list is an array of the relevant data plus an indicator of the next and previous entries, right?
    Sounds easily achievable with any of the plsql collection types.
    The simplest would be a plsql associative array of a record
    Assignments of records in collections is always a bit hamfisted compared to sql objects types though (IMO).
    Something like ?
    DECLARE
    TYPE r_payload IS RECORD
    (col1 number,
      col2 number);
    TYPE r_array_entry is RECORD
    (prev_entry PLS_INTEGER,
      next_entry PLS_INTEGER,
      payload    r_payload);
    TYPE t_array IS TABLE OF r_array_entry INDEX BY PLS_INTEGER;
    v_array t_array;
    BEGIN
    NULL;
    END; 
      The use case for such a structure in properly coded SQL & PL/SQL is possibly the harder question.

  • Can I import my old link lists into 365 site?

    Hi I would like to import all my hard work from my old 2010 sharepoint site into the new 365 site.
    I exported my links to excel but I cannot see an import option on a link list in 365.
    Surely there must be an easy way to do this that I am missing?
    thanks

    Below are the steps to save List as Template:
    >> Go to the List - List Settings - Click on Save List as Template - Provide Template Name and make sure you check the "With Content" box available on the page. 
    Once the List is successfully saved as template, you will find the template under List Templates gallery. Download that template it should have ".stp" extension. Get that file and upload the file to List Templates gallery of your SharePoint Online Office
    365 site. Then create a new app and there you should find the Template and create a list using that template.
    If you have any questions then let me know.
    Please ensure that you mark a question as Answered once you receive a satisfactory response.

  • Saving Linked List to file

    Hello,
    I have a simple linked link. How do I save the entire list into a file, and and how to I restore the entire link list back into the program so that I can use it normally again?
    I guess Serialization is used?
    I don't want to save save all the filds in a file, then "re create" the link list by loops etc.

    Since Serialization saves the object in question and all the objects it references, if you make you're liunked list element Serializable and then save the first element, the Serialization process will save the entire list.
    To get it back, read an Object from the file, it will be the first element of your list and its next link will point at the next element, etc.
    If you have a circular list, this still works since the Serialization process will recognice that your saving the same object a second time and only send a reference.

  • Turning a linked list into a for loop

    Im stupid and cannot figure out how to make this
    lp list1 = new lp(0,new lp(1, new lp(2, new lp(3, new lp(4, new lp(5, new lp(6, new lp(7, new lp(8, new lp(9, null))))))))));
    into a for loop, i know its simple, i finished my first linked list assignmenet but having this in my program is too ugly and i know a loop should fix it

    JosAH wrote:
    cotton.m wrote:
    Ip list = new IP(9,null);
    for(int i descending order starting from 8 and going down to zero)
    list = new Ip(i,list);
    That last/first element can be in the loop too:
    Ip list = null;
    for(int i descending order starting from 9 and going down to zero)
    list = new Ip(i,list);
    }kind regards,
    Josd'oh! Yes that's better. Thanks.

  • N^2 log(n) for Collections.sort() on a linked list in place?

    So, I was looking over the Java API regarding Collections.sort() on linked lists, and it says it dumps linked lists into an array so that it can call merge sort. Because, otherwise, sorting a linked list in place would lead to a complexity of O(n^2 log n) ... can someone explain how this happens?

    corlettk wrote:
    uj,
    ... there are other sorting methods for linked lists with an O(N*N) complexity.Please, what are those algorithms? I'm guesing they're variants off insertion sort, coz an insertion is O(1) in a linked list [and expensive in array]... Am I warm?You don't have to change the structure of a linked list to sort it. You can use an ordinary Bubblesort. (The list is repeatedly scanned. In each scan adjacent elements are compared and if they're in wrong order they're swapped. When one scan of the list passes without any swaps the list is sorted). This is an O(N*N) algoritm.
    What I mean is it's possible to sort a list with O(N*N) complexity. It doesn't have to be O(N*N*logN) as the Java documentation kind of suggests. In fact I wouldn't be surprised if there were special O(N*logN) algoritms available also for lists but I don't know really. In any case Java uses none of them.

  • Saving a LinkedList into a text doc using bufferwriter

    hi
    I'm having some problem attempting to save my linked into a text doc(.txt). By using the scanner class i to read another text doc and have it put each work in that document as an single element in the linkedlist. But when i try to write the linked list into a text doc it only writes the last word / element that is in the linkedlist into a text document. How do i get my bufferwriter or filewrite to same all the words and prehaps in a format that i want?
    import java.util.*;
    import java.io.*;
    public class LibraryLinkedList {
        public static void main(String[] args) throws FileNotFoundException,
       IOException{
          File file1 = new File(args[0]);
            Scanner in = new Scanner(file1);
            LinkedList<String> lst = new LinkedList<String>();
            //... Read and build list of words.
            while (in.hasNext()) {
                String word = in.next();
                lst.add(word);
           ///  loop to print list forward.
            //    Could also use an Iterator (forward only) or
            System.out.println(" Print words in order of entry");
            for (String s : lst) {
                System.out.println(s);
            /// this print statement is for testing
             BufferedWriter out = new BufferedWriter(new FileWriter(
            "s.txt"));
          PrintWriter output = new PrintWriter(out);
          output.print(s);
          output.close();
    }eg.
    1. i have a doc with words("apple chair book house")
    2. i have a testing print statement which prints the words that have been scanned and placed into linked list and it prints it like this
    apple
    chair
    book
    house
    3. then when i attempt to write into a txt doc it only has ("house") in the doc

    hey
    say i wanted to add a numbering system for each linkedlist item, i've used another for loop to try and attempt this but what happens is that it loops too much.
    eg what i wanted was something like
    1. apple 2.house 3. somthing ect
    but what happens is
    1.apple 2.apple 3.apple ... 15.apple 1.house 2.house 3 house..... 15.house
    my code is as follows
    for(String g :lst) {
                for(int i = 1; i < lst.size(); i++){
                //out.write("#" + i); for loop placing numbers and increasing
                out.write(" #"+ i + g);}
      out.write(" "); // add a new line
    out.close();
        }

  • Can you import local tables into Oracle to query in Discoverer?

    long time lurker, first time poster...
    I've got a local list in excel of over 100k records. I want to bounce this list off our network's data in Oracle to add a few fields to my file. Is there a way to import the local list into Oracle (like I might using MS Access) so that I can query the data using Discoverer, and output my local list with the additional data I pull out of Oracle? Thanks so much for any assistance!

    Hi,
    Create an external table in the database that points to the excel workbook then you will be able to query the excel workbook like any other table in Discoverer. You will need to create a database directory which points to the directory containing the excel workbook. You will also have to save the workbook in a csv format. But once that is set up you will be able to make changes in the excel workbook save them, then refresh the Discoverer workbook and immediately see the changed data in Discoverer.
    Rod West

  • Linked List mess

    Hello,
    I think I've gotten myself into a bit of a mess.
    I create a Linked List containing many strings. I do this for 10 separate tabs. I then want to combine Linked Lists into something else like a LinkedList again so I can then write that one combined list to a file. Something like an array but instead it takes in LinkedLists.
    The container of the 10 linked lists will never have more than 10 but will always have 10. If one of the tabs is not enabled I place a filler in for it. This is my code and it is throwing me a null pointer exception and I am sure it is because I initialize CETotalCover to null but I don't know how else I could initialize it. That leads me to believe this is probably not the right choice for what I am doing.
    LinkedList<String>[] CETotalCover = null;     
    LinkedList<String> noCover = new LinkedList();
    noCover.add("***");
    CEArray CEData = new CEArray();
    if (_Dailycover.isEnabled()){
         CETotalCover[0] = CEData.toLayer(_Dailycover.getRowData());
    else{
         CETotalCover[0] = noCover;
    }What would be the best way to do this? Sorry I'm new to Java and haven't had much experience with trying to make a list of lists.
    Edited by: Sch104 on May 19, 2008 10:25 AM
    Edited by: Sch104 on May 19, 2008 10:25 AM

    Correct, you never created an array object to store your lists in, so when you tried to access the first element it blew up. In order to fix that, you need to actually create the array. Unfortunately, generics and arrays do not play nicely together. Use an ArrayList instead.

  • Array of Linked List Help

    I am fairly new to Java, and Linked Lists. Can you tell me how I can fix my code? Why does my code print infinite "3" s. That is all I am trying to do is create a linked list and put that linked list into index 2 of the array. In the loop, I am setting up a whole bunch on null Node's, is it even possible to link all these nodes together in that same loop? If something does not make sense, I will try to elaborate. I will eventually impliment an insert method in the Node class, are there any pointers on how to implement it? What are the special cases I need to be looking for when implementing the insert method?
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package testlinkedlist;
    * @author Ben
    public class Main {
         * @param args the command line arguments
        public static Node l;
        public static Node p = new Node();
        public static Node Front;
        public static void main(String[] args) {
            Node[] anArray = new Node[4];
            for(int i = 0; i < 4; i++){
                anArray[i] = new Node();
                l = new Node(i);
                l.setLink(l);
            anArray[2] = l;         
            while(anArray[2] != null){
                System.out.println(anArray[2].dataInNode());
                anArray[2] = anArray[2].next;
    }

    l = new Node(i);
    l.setLink(l);The node l is created in line one, in line two a link is created from l to l. In other words here is the presence of your infinite loop which is magnified in the following piece of code:
    anArray[2] = l;         
    while(anArray[2] != null){
      System.out.println(anArray[2].dataInNode());
      anArray[2] = anArray[2].next;
    }Mel

  • How to make a linked list?

    I've seen how to implement a linked list in oracle ? but it's not what I'm interested in.
    First of all, it is just a curiosity, no serious task behind it. I think I've almost made a linked list (of chars) type, however it misses the notion of empty list and thus I virtually cannot construct it.
    create or replace type LString as object
      head Char,
      tail ref LString,
      member function cons(
        p_x Char)
        return LString
    create or replace type body LString is
      member function cons(
        p_x Char)
        return LString
      is
        xs LString;
      begin
        xs := LString(head => p_x, tail => self.tail);
        return xs;
      end;
    end;I need to be able to make empty list to construct other lists, for example:
    empty_lstring.cons('H').cons('i').cons('!')
    How can I do it?
    Edited by: 922141 on 12.07.2012 7:02

    I need to be able to make empty list to construct other lists, for example:
    empty_lstring.cons('H').cons('i').cons('!')
    Why ? Can you mention one procedural language who can do this? I can't! Can you?
    Sybrand Bakker
    Senior Oracle DBA

  • Converting an array to a Linked list.

    I'm writing somewhat of a card game. One of the functions I'm supposed to have is the cut function. I'm supposed to split the deck into two and place the bottom half on top of the top half. My card objects are stored in Nodes in a programmer defined linked list. I believe I successfully converted the linked list into two array (top and bottom) but I am having problems with converting these back to LinkedList (atleast thats where I think my problem is) This is the code i had so far:
         public void cut()
              if (isEmpty())
                   throw new DeckException("Deck of Cards");
              else
                   int pivot = (int)(Math.random()*numCards);
                   Node top[] = new Node[pivot];
                   Node bottom[] = new Node[numCards-pivot];
                   Node traveller = front;
                            //Convert the linkedList into two arrays
                   for(int i = 0; i < numCards; i++)
                        if(i < pivot)
                             top[i] = traveller;
                             traveller = traveller.getNext();
                        else
                             bottom[i-pivot] = traveller;
                             traveller = traveller.getNext();
                            //Convert the two arrays back to a LinkedList, where bottom is put in the front of the list and top is put on the end
                   traveller = front;
                   for(int i = 0; i < numCards; i++)
                        if(i < bottom.length)
                                            //reference comment 1
                             traveller.setNext(bottom);
                             traveller = traveller.getNext();
                        else
    //reference comment 2
                             traveller.setNext(top[i-bottom.length]);
                             traveller = traveller.getNext();
         }I'm not really sure what I'm doing wrong but when i play around with the code I get alot of ArrayOutOfBounds error around the comment above marked as reference comment 1 and 2
    Can someone please give me guidance as to what I'm doing wrong? I feel as If I've reached a block i can't get past.
    EDIT: the variable numCards above should have the value 52
    Edited by: 806583 on Oct 31, 2010 11:12 PM

    My Node class is public. It does not implement the List Interface. This is my Node class:package project3;
    public class Node
      private Card data; //a reference to an object of type T
      private Node next; //the address of the next node in the list
       * default constructor - initializes data and next to null
      public Node()
           data = null;
           next = null;
       * parameterized constructor - initializes data to the user
       * specified value; next is set to null
       * @param newItem the value to be stored in the node
      public Node(Card newItem)
        data = newItem;
        next = null;
       * parameterized constructor - initializes data and next to user
       * specified values
       * @param newItem the object reference to be stored in the node
       * @param nextItem the reference to the next node in the list
      public Node(Card newItem, Node nextItem)
        data = newItem;
        next = nextItem;
       * setItem - stores a new value in data
       * @param newItem the object reference to be stored in the node
      public void setItem(Card newItem)
        data = newItem;
       * setNext - stores a new value in next
       * @param nextItem the reference to be stored in next
      public void setNext(Node nextItem)
        next = nextItem;
       * getItem - returns the reference stored in data
       * @return a reference to the data stored in the node
      public Card getItem()
        return data;
       * getNext - returns the reference stored in next
       * @return the reference stored in next
      public Node getNext()
        return next;
    }

  • Help Implementing a queue as a circular linked list...

    I have a set of code that I need to implement a circular linked list into, but I am not sure how to approach it at all. If anyone can point me to some pseudo code or sample code that I can modify for my use, that would be great.
    I created a Class CircularQueue, which implements Queue, I just need to figure out how to write it.
    Heres the code I have:
    Queue Interface
    public interface Queue<ElementType> {
         public void enqueue(ElementType e);
         public ElementType dequeue();
         public ElementType front();
         public boolean isEmpty();
    Data Holder
    public class DataHolder<ElementType> {
         // instance variables
         private ElementType _data;
          * Constructor for objects of class DataHolder
         public DataHolder() {
              _data = null;
         public void setContents(ElementType anItem) {
              _data = anItem;
         public ElementType getContents() {
             return _data;
    DeqeueButton
    import javax.swing.*;
    import java.awt.event.*;
    public class DequeueButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class DequeueButton
        public DequeueButton(QueuePanel aQueuePanel) {
            super("Dequeue");
            _queuePanel = aQueuePanel;
            _queue = aQueuePanel.getQueue();
            this.addActionListener(new DequeueButtonListener());
        private class DequeueButtonListener implements ActionListener {
            private final int MOVE_LENGTH = 25;    // square size + 5
            public void actionPerformed(ActionEvent e) {
                _queue.dequeue();   // remove item from queue
                _queuePanel.repaint();
    EnqueueButton
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EnqueueButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class EnqueueButton
        public EnqueueButton(QueuePanel aQueuePanel) {
            super("Enqueue");
            _queuePanel = aQueuePanel;
            _queue = _queuePanel.getQueue();
            this.addActionListener(new EnqueueButtonListener());
        private class EnqueueButtonListener implements ActionListener {
            private int _nextX, _nextY;
            private final int SQUARE_SIZE = 20;
            private final int MAX_X = 550;
            private final int MAX_Y = 350;
            private Color _currentColor;
            public EnqueueButtonListener() {
                _currentColor = Color.BLUE;
                _nextX = MAX_X;
                _nextY = MAX_Y;
            public void actionPerformed(ActionEvent e) {
                _queue.enqueue(new SmartRectangle(_nextX, _nextY, SQUARE_SIZE, SQUARE_SIZE, _currentColor, _queuePanel));
                this.changeColor();
                _nextX -= (SQUARE_SIZE+5);  // location of next square in line
                if (_nextX < 0)     // if we reach edge of window, wrap
                {   _nextY -= (SQUARE_SIZE+5);
                    _nextX = MAX_X;
                if (_nextY < 0)     // start over
                    _nextY = MAX_Y;
                _queuePanel.repaint();
            public void changeColor() {
                if (_currentColor == Color.BLUE)          
                    _currentColor = Color.RED;
                else if (_currentColor == Color.RED)      
                    _currentColor = Color.GREEN;
                else if (_currentColor == Color.GREEN)    
                    _currentColor = Color.YELLOW;
                else if (_currentColor == Color.YELLOW)   
                    _currentColor = Color.BLACK;
                else if (_currentColor == Color.BLACK)    
                    _currentColor = Color.BLUE;
    FrontButton
    import javax.swing.*;
    import java.awt.event.*;
    public class FrontButton extends JButton {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private QueuePanel _queuePanel;
         * Constructor for objects of class DequeueButton
        public FrontButton(QueuePanel aQueuePanel) {
            super("Front");
            _queuePanel = aQueuePanel;
            _queue = aQueuePanel.getQueue();
            this.addActionListener(new FrontButtonListener());
        private class FrontButtonListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                SmartRectangle rectangle = _queue.front();    // remove item from queue
                SmartRectangle displayRect = _queuePanel.getDisplayFrontRect();
                if (rectangle != null)
                    displayRect.setColor(rectangle.getColor());
                _queuePanel.repaint();
    QueueApp
    import javax.swing.*;
    import java.awt.*;
    public class QueueApp extends JFrame
         * Constructor for objects of class QueueApp
        public QueueApp(String title)
            super(title);
            this.setSize(600,450);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            QueuePanel queuePanel = new QueuePanel();
            javax.swing.JPanel buttonPanel = new JPanel(new FlowLayout());
            buttonPanel.add(new EnqueueButton(queuePanel));
            buttonPanel.add(new DequeueButton(queuePanel));
            buttonPanel.add(new FrontButton(queuePanel));
            this.add(queuePanel, BorderLayout.CENTER);
            this.add(buttonPanel, BorderLayout.SOUTH);
            this.setVisible(true);     
        public static void main (String [] args)
            QueueApp app = new QueueApp("Queues at work: Object Oriented implementation.");
    QueuePanel
    import javax.swing.*;
    import java.awt.*;
    public class QueuePanel extends javax.swing.JPanel {
        // instance variables
        private Queue<SmartRectangle> _queue;
        private SmartRectangle _frontRect;
         * Constructor for objects of class QueuePanel
        public QueuePanel() {
            super();
            _queue = new CircularQueue<SmartRectangle>();
            _frontRect = new SmartRectangle(50,50,20,20,Color.WHITE, this);
       public Queue<SmartRectangle> getQueue() {
           return _queue;
       public SmartRectangle getDisplayFrontRect() {
           return _frontRect;
       public void paintComponent(Graphics aBrush) {
           super.paintComponent(aBrush);
           Graphics2D aBetterBrush = (Graphics2D) aBrush;
           Queue<SmartRectangle> tempQueue = new CircularQueue<SmartRectangle>();
           if (_frontRect.getColor() != this.getBackground())
               _frontRect.fill(aBetterBrush);
           while (!_queue.isEmpty()) {       // remove and display contents
               SmartRectangle rectangle = _queue.dequeue();
               rectangle.fill(aBetterBrush);
               tempQueue.enqueue(rectangle);
           while (!tempQueue.isEmpty()) {    // put contents back into _queue
               _queue.enqueue(tempQueue.dequeue());
           _frontRect.setColor(this.getBackground());
    SmartNode
    public abstract class SmartNode<ElementType> {
         public abstract boolean isEmpty();
         public abstract SmartNode<ElementType> dequeue(DataHolder<ElementType> aHolder);
         public abstract void front(DataHolder<ElementType> aHolder);
         public void enqueue(ElementType anItem){}
         public void setNext(SmartNode<ElementType> aNode) {
         }  // override as needed
         public void setPrev(SmartNode<ElementType> aNode) {
         }  // override as needed
    SmartRectangle
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    public class SmartRectangle extends Rectangle2D.Double {
        // instance variables
        private JPanel _panel;
        private Color _color;
         * Constructor for objects of class SmartRectangle
        public SmartRectangle(int x, int y, int aWidth, int aHeight, Color aColor,
                              JPanel aPanel) {
            super(x, y, aWidth, aHeight);
            _panel = aPanel;
            _color = aColor;
        public void setLocation (int x, int y) {
            this.setFrame(x, y, this.getWidth(), this.getHeight());
        public Color getColor() {
            return _color;
        public void setColor(Color aColor) {
            _color = aColor;
        public void fill(Graphics2D aPaintBrush) {
            Color savedColor = aPaintBrush.getColor();
            aPaintBrush.setColor(_color);
            aPaintBrush.fill(this);
            aPaintBrush.setColor(savedColor);
    }

    > Yea I think I understand the concept of it, but I
    dont know what the code is supposed to look like.
    Showing you what the code is supposed to look like would be effectively giving you the answer, which kind of defeats the purpose of "extra credit". Have you tried anything so far? Post what you've got, and we can give you hints on how to work through it. I thought some of the descriptions here were very explicit hints, but if you need some additional guidance, let us know your specific questions (other than "show me the code").
    Good luck!
    ~

  • Saving to text file from GUI within linked list

    can anyone help me with saving to a text file from a GUI text area and text fields??
    then reading back into the labels and textfields from the text file??
    It's currently just saving in a linked list and creating a new item inside of it. but i have to now make a text file for each item, this is what i currently have
    i need to turn this into something that with save to text file with buffered reader or something, can anyone help???
    public void saveToFile()
            while(listIterator.hasNext())
                item = (Item)listIterator.next();
                saving.save(item);
        }//END SAVETOFILE
        public Object save(Item item)
            if (last == 1)
                itemList.set( listIterator.nextIndex() , item);
            else
                itemList.set(listIterator.previousIndex(), item);
            itemList.set(listIterator.previousIndex(), item);
            listIterator = itemList.listIterator(0);
            return itemList.getFirst();   
        }//END SAVE

    thank you sztyopek, i am still having trouble getting it to save to text file. I have to do it through a client and server so i have a protocol class. in the protocol class i have
    if (o instanceof String)
                        //System.out.println(o);
                        if (o.equals("next"))
                            newo = database.getNextItem();
                           // some how send newo
                        if (o.equals("prev"))
                            newo = database.getPrevItem();
                            //some how send newo
                        if (o.equals("save"))
                            database.saveToFile();
                        if (o.equals("exit"))
                            System.exit(1);
                    }//END IF STRING
             if (o instanceof Item)
               newo = database.save((Item)o);
            return newo;
        }When i save what i have entered in the textfields for each record it doesn't create a textfile. and it still getting retrieved from how i set it up before by going to the database.save((Item)o)...the last if statement above but i can't change that to the saveToFile method that u helped me with it says incompatible types or something.
    this is the method it is going to, i assume i have to get rid of this so i stop getting the information from the list and start getting it from the text file.
    public Object save(Item item)
            if (last == 1)
                itemList.set( listIterator.nextIndex() , item);
            else
                itemList.set(listIterator.previousIndex(), item);
            itemList.set(listIterator.previousIndex(), item);
            listIterator = itemList.listIterator(0);
            return itemList.getFirst();   
        }//END SAVEif this makes any sense can u give me a hand.
    As to rob the guy bagging me........i am doing a bachelor of networking and they make us do java for the first year. this is my last semester and last assignment. it is also the last thing i have to do for the assignment. I am not good at java so that is why i am asking for some help i just want to pass this semester then i am never doing it again.
    thanks.

  • Splitting a Linked List at a Given Node, into Two Sublists??

    My code just will not work!! Any help would be appreciated! My problem is in the last method SplitAt. These are the conditions set and my code:
    Splitting a Linked List at a Given Node, into Two Sublists
    a. Add the following as an abstract method to the class
    LinkedListClass:
    public void splitAt (LinkedListClass<T> secondList, T item);
    //This method splits the list at the node with the info item into two sublists.
    //Precondition: The list must exist.
    //Postcondition: first and last point to the first and last nodes of the first sublist,
    // respectively. secondList.first and secondList.last point to the first
    // and last nodes of the second sublist.
    Consider the following statements:
    UnorderedLinkedList<Integer> myList;
    UnorderedLinkedList<Integer> otherList;
    Suppose myList points to the list with the elements 34, 65, 18, 39, 27, 89, and 12 (in this order). The statement
    myList.splitAt(otherList, 18);
    splits myList into two sublists: myList points to the list with elements 34 and 65, and otherList points to the sublist with elements 18, 39, 27, 89, and 12.
    b. Provide the definition of the method splitAt in the class UnorderedLinkedList. Also write a program to test your method.
    public class UnorderedLinkedList<T> extends LinkedListClass<T>
    //Default constructor
    public UnorderedLinkedList()
    super();
    //Method to determine whether searchItem is in
    //the list.
    //Postcondition: Returns true if searchItem is found
    // in the list; false otherwise.
    public boolean search(T searchItem)
    LinkedListNode<T> current; //variable to traverse
    //the list
    boolean found;
    current = first; //set current to point to the first
    //node in the list
    found = false; //set found to false
    while (current != null && !found) //search the list
    if (current.info.equals(searchItem)) //item is found
    found = true;
    else
    current = current.link; //make current point to
    //the next node
    return found;
    //Method to insert newItem in the list.
    //Postcondition: first points to the new list
    // and newItem is inserted at the
    // beginning of the list. Also,
    // last points to the last node and
    // count is incremented by 1.
    public void insertFirst(T newItem)
    LinkedListNode<T> newNode; //variable to create the
    //new node
    newNode =
    new LinkedListNode<T>(newItem, first); //create and
    //insert newNode before
    //first
    first = newNode; //make first point to the
    //actual first node
    if (last == null) //if the list was empty, newNode is
    //also the last node in the list
    last = newNode;
    count++; //increment count
    //Method to insert newItem at the end of the list.
    //Postcondition: first points to the new list and
    // newItem is inserted at the end
    // of the list. Also, last points to
    // the last node and
    // count is incremented by 1.
    public void insertLast(T newItem)
    LinkedListNode newNode; //variable to create the
    //new node
    newNode =
    new LinkedListNode(newItem, null); //create newNode
    if (first == null) //if the list is empty, newNode is
    //both the first and last node
    first = newNode;
    last = newNode;
    else //if the list is not empty, insert
    //newNode after last
    last.link = newNode; //insert newNode after last
    last = newNode; //set last to point to the
    //actual last node
    count++;
    }//end insertLast
    //Method to delete deleteItem from the list.
    //Postcondition: If found, the node containing
    // deleteItem is deleted from the
    // list. Also, first points to the first
    // node, last points to the last
    // node of the updated list, and count
    // is decremented by 1.
    public void deleteNode(T deleteItem)
    LinkedListNode<T> current; //variable to traverse
    //the list
    LinkedListNode<T> trailCurrent; //variable just
    //before current
    boolean found;
    if ( first == null) //Case 1; the list is empty
    System.err.println("Cannot delete from an empty "
    + "list.");
    else
    if (first.info.equals(deleteItem)) //Case 2
    first = first.link;
         if (first == null) //the list had only one node
         last = null;
         count--;
    else //search the list for the given info
    found = false;
    trailCurrent = first; //set trailCurrent to
    //point to the first node
    current = first.link; //set current to point to
    //the second node
    while (current != null && !found)
    if (current.info.equals(deleteItem))
    found = true;
    else
    trailCurrent = current;
    current = current.link;
    }//end while
    if (found) //Case 3; if found, delete the node
    count--;
    trailCurrent.link = current.link;
    if (last == current) //node to be deleted
    //was the last node
    last = trailCurrent; //update the value
    //of last
    else
    System.out.println("Item to be deleted is "
    + "not in the list.");
    }//end else
    }//end else
    }//end deleteNode
    public void splitAt(LinkedListClass<T> secondList, T item)
    LinkedListNode<T> current;
    LinkedListNode<T> trailCurrent;
    int i;
    boolean found;
    if (first==null)
    System.out.println("Empty.");
    first=null;
    last=null;
    count--;
    else
         current=first;
         found=false;
         i=1;
         while(current !=null &&!found)
              if(current.info.equals(secondList))
                   found= true;
                   else
                        trailCurrent=current;
                        i++;
         if(found)
              if(first==current)
                   first=first;
                   last=last;
                   count=count;
                   count=0;
              else
                   first=current;
                   last=last;
                   last=null;
                   count = count- i+1;
                   count = i-1;
              else
                   System.out.println("Item to be split at is "
    + "not in the list.");
              first=null;
              last=null;
              count=0;
    }

    I dont have a test program at all. The program is supposed to prompt for user input of numbers. (it does) Take the input and end at input of -999 (it does). Then it asks user where it wants to split list (it does). When I enter a number it does nothing after that. I am going to post updated code and see if that helps along with all the classes. Thanks!
    This is the class to prompt:
    import java.util.*;
    public class Ch16_ProgEx6
        static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
             UnorderedLinkedList<Integer> list
                              = new UnorderedLinkedList<Integer>();
            UnorderedLinkedList<Integer> subList =
                              new UnorderedLinkedList<Integer>();
             Integer num;
             System.out.println("Enter integers ending with -999.");
             num = console.nextInt();
             while (num != -999)
                 list.insertLast(num);
                 num = console.nextInt();
            System.out.println();
            System.out.println("list: ");
            list.print();
            System.out.println();
            System.out.println("Length of list: " + list.length());
            System.out.print("Enter the number at which to split list: ");
            num = console.nextInt();
            list.splitAt(subList, num);
            System.out.println("Lists after splitting list");
            System.out.print("list: ");
            list.print();
            System.out.println();
            System.out.println("Length of list: " + list.length());
            System.out.print("sublist: ");
            subList.print();
            System.out.println();
            System.out.println("Length of sublist: " + subList.length());
    }This is the ADT:
    public interface LinkedListADT<T> extends Cloneable
        public Object clone();
           //Returns a copy of objects data in store.
           //This method clones only the references stored in
           //each node of the list. The objects that the
           //list nodes point to are not cloned.
        public boolean isEmptyList();
           //Method to determine whether the list is empty.
           //Postcondition: Returns true if the list is empty;
           //               false otherwise.
        public void initializeList();
           //Method to initialize the list to an empty state.
           //Postcondition: The list is initialized to an empty
           //               state.
        public void print();
           //Method to output the data contained in each node.
        public int length();
           //Method to return the number of nodes in the list.
           //Postcondition: The number of nodes in the list is
           //               returned.
        public T front();
           //Method to return a reference of the object containing
           //the data of the first node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the first node
           //               is returned.
        public T back();
           //Method to return a reference of object containing
           //the data of the last node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the last node
           //               is returned.
        public boolean search(T searchItem);
           //Method to determine whether searchItem is in the list.
           //Postcondition: Returns true if searchItem is found
           //               in the list; false otherwise.
        public void insertFirst(T newItem);
           //Method to insert newItem in the list.
           //Postcondition: newItem is inserted at the
           //               beginning of the list.
        public void insertLast(T newItem);
           //Method to insert newItem at the end of the list.
           //Postcondition: newItem is inserted at the end
           //               of the list.
        public void deleteNode(T deleteItem);
           //Method to delete deleteItem from the list.
           //Postcondition: If found, the node containing
           //               deleteItem is deleted from the
           //               list.
        public void splitAt(LinkedListClass<T> secondList, T item);
    }This is the linked list class:
    import java.util.NoSuchElementException;
    public abstract class LinkedListClass<T> implements LinkedListADT<T>
        protected class LinkedListNode<T> implements Cloneable
            public T info;
            public LinkedListNode<T> link;
               //Default constructor
               //Postcondition: info = null; link = null;
            public LinkedListNode()
                info = null;
                link = null;
               //Constructor with parameters
               //This method sets info pointing to the object to
               //which elem points to and link is set to point to
               //the object to which ptr points to.
               //Postcondition:  info = elem; link = ptr;
            public LinkedListNode(T elem, LinkedListNode<T> ptr)
                info = elem;
                link = ptr;
               //Returns a copy of objects data in store.
               //This method clones only the references stored in
               //the node. The objects that the nodes point to
               //are not cloned.
            public Object clone()
                LinkedListNode<T> copy = null;
                try
                    copy = (LinkedListNode<T>) super.clone();
                catch (CloneNotSupportedException e)
                    return null;
                return copy;
               //Method to return the info as a string.
               //Postcondition: info as a String object is
               //               returned.
            public String toString()
                return info.toString();
        } //end class LinkedListNode
        public class LinkedListIterator<T>
            protected LinkedListNode<T> current;  //variable to
                                                  //point to the
                                                  //current node in
                                                  //list
            protected LinkedListNode<T> previous; //variable to
                                                  //point to the
                                                  //node before the
                                                  //current node
               //Default constructor
               //Sets current to point to the first node in the
               //list and sets previous to null.
               //Postcondition: current = first; previous = null;
            public LinkedListIterator()
                current = (LinkedListNode<T>) first;
                previous = null;
               //Method to reset the iterator to the first node
               //in the list.
               //Postcondition: current = first; previous = null;
            public void reset()
                current = (LinkedListNode<T>) first;
                previous = null;
               //Method to return a reference of the info of the
               //current node in the list and to advance iterator
               //to the next node.
               //Postcondition: previous = current;
               //               current = current.link;
               //               A refrence of the current node
               //               is returned.
            public T next()
                if (!hasNext())
                    throw new NoSuchElementException();
                LinkedListNode<T> temp = current;
                previous = current;
                current = current.link;
                return temp.info;
                //Method to determine whether there is a next
                //element in the list.
                //Postcondition: Returns true if there is a next
                //               node in the list; otherwise
                //               returns false.
            public boolean hasNext()
                return (current != null);
               //Method to remove the node currently pointed to
               //by the iterator.
               //Postcondition: If iterator is not null, then the
               //               node that the iterator points to
               //               is removed. Otherwise the method
               //               throws NoSuchElementException.
            public void remove()
                if (current == null)
                    throw new NoSuchElementException();
                if (current == first)
                    first = first.link;
                    current = (LinkedListNode<T>) first;
                    previous = null;
                    if (first == null)
                        last = null;
                else
                    previous.link = current.link;
                    if (current == last)
                        last = first;
                        while (last.link != null)
                            last = last.link;
                    current = current.link;
                count--;
               //Method to return the info as a string.
               //Postcondition: info as a String object is returned.
            public String toString()
                return current.info.toString();
        } //end class LinkedListIterator
           //Instance variables of the class LinkedListClass
        protected LinkedListNode<T> first; //variable to store the
                                           //address of the first
                                           //node of the list
        protected LinkedListNode<T> last;  //variable to store the
                                           //address of the last
                                           //node of the list
        protected int count;  //variable to store the number of
                              //nodes in the list
           //Default constructor
           //Initializes the list to an empty state.
           //Postcondition: first = null, last = null,
           //               count = 0
        public LinkedListClass()
            first = null;
            last = null;
            count = 0;
           //Method to determine whether the list is empty.
           //Postcondition: Returns true if the list is empty;
           //               false otherwise.
        public boolean isEmptyList()
            return (first == null);
           //Method to initialize the list to an empty state.
           //Postcondition: first = null, last = null,
           //               count = 0
        public void initializeList()
            first = null;
            last = null;
            count = 0;
           //Method to output the data contained in each node.
        public void print()
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            current = first;    //set current so that it points to
                                //the first node
            while (current != null) //while more data to print
                System.out.print(current.info + " ");
                current = current.link;
        }//end print
           //Method to return the number of nodes in the list.
           //Postcondition: The value of count is returned.
        public int length()
            return count;
           //Method to return a reference of the object containing
           //the data of the first node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the first node
           //               is returned.
        public T front()
            return first.info;
            //Method to return a reference of object containing
            //the data of the last node of the list.
            //Precondition: The list must exist and must not be empty.
            //Postcondition: The reference of the object that
            //               contains the info of the last node
            //               is returned.
        public T back()
            return last.info;
           //Returns a copy of objects data in store.
           //This method clones only the references stored in
           //each node of the list. The objects that the
           //list nodes point to are not cloned.
        public Object clone()
            LinkedListClass<T> copy = null;
            try
                copy = (LinkedListClass<T>) super.clone();
            catch (CloneNotSupportedException e)
                return null;
                //If the list is not empty clone each node of
                //the list.
            if (first != null)
                   //Clone the first node
                copy.first = (LinkedListNode<T>) first.clone();
                copy.last = copy.first;
                LinkedListNode<T> current;
                if (first != null)
                    current = first.link;
                else
                    current = null;
                   //Clone the remaining nodes of the list
                while (current != null)
                    copy.last.link =
                            (LinkedListNode<T>) current.clone();
                    copy.last = copy.last.link;
                    current = current.link;
            return copy;
           //Method to return an iterator of the list.
           //Postcondition: An iterator is instantiated and
           //               returned.
        public LinkedListIterator<T> iterator()
            return new LinkedListIterator<T>();
           //Method to determine whether searchItem is in
           //the list.
           //Postcondition: Returns true if searchItem is found
           //               in the list; false otherwise.
        public abstract boolean search(T searchItem);
           //Method to insert newItem in the list.
           //Postcondition: first points to the new list
           //               and newItem is inserted at the
           //               beginning of the list. Also,
           //               last points to the last node and
           //               count is incremented by 1.
        public abstract void insertFirst(T newItem);
           //Method to insert newItem at the end of the list.
           //Postcondition: first points to the new list and
           //               newItem is inserted at the end
           //               of the list. Also, last points to
           //               the last node and
           //               count is incremented by 1.
        public abstract void insertLast(T newItem);
           //Method to delete deleteItem from the list.
           //Postcondition: If found, the node containing
           //               deleteItem is deleted from the
           //               list. Also, first points to the first
           //               node, last points to the last
           //               node of the updated list, and count
           //               is decremented by 1.
        public abstract void deleteNode(T deleteItem);
        public abstract void splitAt(LinkedListClass<T> secondList, T item);
    }And this is the UnorderedLinked Class with the very last method the one being Im stuck on. The SplitAt Method.
    public class UnorderedLinkedList<T> extends LinkedListClass<T>
           //Default constructor
        public UnorderedLinkedList()
            super();
            //Method to determine whether searchItem is in
            //the list.
            //Postcondition: Returns true if searchItem is found
            //               in the list; false otherwise.
        public boolean search(T searchItem)
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            boolean found;
            current = first;  //set current to point to the first
                              //node in the list
            found = false;    //set found to false
            while (current != null && !found) //search the list
                if (current.info.equals(searchItem)) //item is found
                    found = true;
                else
                   current = current.link; //make current point to
                                           //the next node
            return found;
            //Method to insert newItem in the list.
            //Postcondition: first points to the new list
            //               and newItem is inserted at the
            //               beginning of the list. Also,
            //               last points to the last node and
            //               count is incremented by 1.
        public void insertFirst(T newItem)
            LinkedListNode<T> newNode;     //variable to create the
                                        //new node
            newNode =
               new LinkedListNode<T>(newItem, first); //create and
                                           //insert newNode before
                                           //first
            first = newNode;   //make first point to the
                               //actual first node
            if (last == null)   //if the list was empty, newNode is
                                //also the last node in the list
                last = newNode;
            count++;     //increment count
            //Method to insert newItem at the end of the list.
            //Postcondition: first points to the new list and
            //               newItem is inserted at the end
            //               of the list. Also, last points to
            //               the last node and
            //               count is incremented by 1.
        public void insertLast(T newItem)
            LinkedListNode newNode; //variable to create the
                                    //new node
            newNode =
               new LinkedListNode(newItem, null);  //create newNode
            if (first == null)  //if the list is empty, newNode is
                                //both the first and last node
                first = newNode;
                last = newNode;
            else     //if the list is not empty, insert
                     //newNode after last
                last.link = newNode; //insert newNode after last
                last = newNode;      //set last to point to the
                                     //actual last node
            count++;
        }//end insertLast
            //Method to delete deleteItem from the list.
            //Postcondition: If found, the node containing
            //               deleteItem is deleted from the
            //               list. Also, first points to the first
            //               node, last points to the last
            //               node of the updated list, and count
            //               is decremented by 1.
        public void deleteNode(T deleteItem)
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            LinkedListNode<T> trailCurrent; //variable just
                                            //before current
            boolean found;
            if ( first == null)    //Case 1; the list is empty
                System.err.println("Cannot delete from an empty "
                                 + "list.");
            else
                if (first.info.equals(deleteItem)) //Case 2
                    first = first.link;
                       if (first == null)  //the list had only one node
                          last = null;
                       count--;
                else  //search the list for the given info
                    found = false;
                    trailCurrent = first; //set trailCurrent to
                                          //point to the first node
                    current = first.link; //set current to point to
                                          //the second node
                    while (current != null && !found)
                        if (current.info.equals(deleteItem))
                            found = true;
                        else
                            trailCurrent = current;
                            current = current.link;
                    }//end while
                    if (found) //Case 3; if found, delete the node
                        count--;
                        trailCurrent.link = current.link;
                        if (last == current)  //node to be deleted
                                              //was the last node
                           last = trailCurrent;  //update the value
                                                 //of last
                    else
                       System.out.println("Item to be deleted is "
                                        + "not in the list.");
                }//end else
            }//end else
        }//end deleteNode
        public void splitAt(LinkedListClass<T> secondList, T item)
         LinkedListNode<T> current;
         LinkedListNode<T> trailCurrent;
         int i;
         boolean found;
         if (first==null)
        System.out.println("Empty.");
        first=null;
        last=null;
        count--;
        count=0;
         else
              current=first;
              found=false;
              i=1;
              while(current !=null &&!found)
                   if(current.info.equals(item))
                       found= true;
                       else
                            trailCurrent=first;
                            current=first;
                            i++;
              if(found)
                   if(first==current)
                        first.link=first;
                        last.link=last;
                           count--;
                        count=0;
                   else
                        first.link=current;
                        last.link=last;
                        last=null;
                        count = count- i+1;
                        count = i-1;
              } else  {
                  System.out.println("Item to be split at is "
                    + "not in the list.");
                   first=null;
                   last=null;
                   count=0;
        Any help or just advice would be fine. Im not the best at Java, better at VB. Am completely stumped! Thanks so much!

Maybe you are looking for

  • Poor battery performance and poor earphones and no...

    My new lumia 520 doesn't last 2.5 hrs with data connection on without any downloading. Even with data connection off and background programs blocked battery drains too quickly. That's too bad for a phone. Am I to keep the phone always in standby and

  • Sharing Itunes store account

    I recently received a gift card for the itunes store and have tried to share it with my daughter, but it's not clear how to do this. Do we simply log into the same account from different computers to buy songs? If so, are those songs playable on both

  • Different signded jar in the same web start app

    Hi there I have a web start application that use an external security provider. The jar file of the security provider is signed (otherwise it don't run under jdk 1.4.1) and the jar with my application is also signed with other signature, because i ne

  • Issue with items that really do have a 0 (zero) price.

    If we have items that have a price of 0.  SAP allows us to enter this in price lists but does not agree when we use this item on an order because it does not accept that the price is 0. Please tell us what we should do. I do not like the solution of

  • How to add JPGS with bad ICC profile?

    I've just started using LR 3 64 (with the newest update) and I've run into a problem with some JPG files. After import, I just get a blank box with a warning triangle, and I can't view them. If I tell it to edit the file in CS5, CS5 gives me a warnin