A part of my hw is generate a doubly linked list which has the data from an input file ("shopping.in")

i am using tokenizer, but however, everytime i try to put the token into the list and print, it gives me a memory place (Dnote@1289321wutever)

please help me, this is due on friday. :cry:

Or if anyone has the code which is similiar to my HW will be highly appericated. thanks

Recommended Answers

All 4 Replies

>Or if anyone has the code which is similiar to my HW will be highly appericated.
No, you do your own homework. If you post your code then we can help you with it, but we won't give you the program.

>No, you do your own homework. If you post your code then we can help you with it, but we won't give you the program.

k i am in a class right now, and i will get off around 3pm.
soon as i get home, i will post that part of my code, and please take a look it aournd 4 or 5 if possible

greatly appericated

import java.io.StreamTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;

public class DoubleLinkedList {

    public static void main(String args[]) {
        //linkedList myList = new linkedList();

    public static void read(String path)
    int tokenType;
    DList myList = new DList();
        Reader reader = new BufferedReader(new FileReader(path));
        StreamTokenizer st = new StreamTokenizer(reader);

                myList.addElement(Double.toString(st.nval), Double.toString(st.nval));
    catch(Exception e)
        System.out.println("exiting ...");
class DList{
 private int numElts;  //number of elements in thelist
 private DNode head, tail;  //keep track of the head and tail of the list

 public DList(){
  numElts = 0;
  head = new DNode(null,null,null,null);
  tail = new DNode(head, null,null,null);

 //return the size of the list
 public int size(){ return numElts;}

 //return true if the list is empty; otherwise, return false
 public boolean isEmpty(){ return (numElts <1);}

 //add an element into the list
 public void addElement(Object e1, Object e2){
  DNode newNode = new DNode(null,null,e1,e2);
  if (!isEmpty()) {
  else {
  numElts ++;

 //swap two elements in the list
 public void swapElements(DNode n1, DNode n2){
  Object temp = n1.getElement1();
  Object temp2 = n1.getElement2();

 //return the first node of the list
 public DNode first(){
  if(isEmpty()) return null;
  return head.getNext();

 //return the last node of the list
 public DNode last(){
  if(isEmpty()) return null;
  return tail.getPrev();
class DNode{
 private DNode prev, next;
 private Object element1, element2;

 public DNode(DNode newPrev, DNode newNext, Object elem1, Object elem2){
  prev = newPrev;
  next = newNext;
  element1 = elem1;
  element2 = elem2;

 //Accessor methods
 public DNode getNext() {return next;}
 public DNode getPrev() {return prev;}
 public Object getElement1() {return element1;}
 public Object getElement2() {return element2;}

 //update methods
 public void setNext(DNode newNext) {next=newNext;}
 public void setPrev(DNode newPrev) {prev=newPrev;}
 public void setElement1(Object newElement) {element1=newElement;}
 public void setElement2(Object newElement) {element2=newElement;}


OK, this is what i have so far, if i run the program, it will return me "DList@108786b"

tokenizer for sure works, i tried it.

any help? thanks

NVM!!! i figured
i am dumbass, gotta use getData().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.