public class Node { private int element; private Node next; public int getElement(){ return element; } public void setElement(int e){ element = e; } public Node getNext() { return next; } public void setNext(Node n) { next = n; } } 
  • I wrote the usual list, but I can not two-dimensional. I can not understand how I move the tail and pointers on it. - Ksenia
  • in general, it is already written in Java and, if desired, you can see its implementation there and copy it for yourself ... - Gorets
  • I need my own implementation using pointers - Ksenia
  • one
    there are no pointers in Java =) (trollface) - Gorets
  • one
    Correctly think @Ksenia. Although everyone in Java calls it a link, but in fact it’s still a pointer (only there is not a direct machine memory address, as in C). - avp

1 answer 1

  1. Read materiel here. Data structures in pictures. Linkedlist .
  2. Watch the source, i.e. your assignment is here. .
  • Could you at least write a part of the code to me, I just have a problem with the tail, I can't move them that easily. - Ksenia
  • The author of the code (by reference) is good. I like his books. - rasmisha
  • to be honest it is even difficult to read, temp'y are rippling in the eyes, and so because what I see is why temphead, temptail? how does head, tail equate number? if these are objects - rasmisha
  • @Ksenia, head = tail = 1; and tail = 2; it does not climb into any gate. You want to make a list of 2 items. Why not just write? head = new Element (); head.value = 1; tail = = new Element (); tail.value = 2; - But this is all essentially wrong. Create a KseniaList class with the Element head, tail, and int count fields. Such is the specialized list. new KseniaList () will create an empty (with count = 0) list. In the Element class, make the next, prev, and value fields. In this class, do the KseniaList methods you need to manipulate the list. And no global variables - avp