Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Liste {
- public ListenElement head, foot;
- public Liste() {
- head = foot = null;
- }
- public void insert(int z){
- ListenElement wert = new ListenElement(z);
- wert.next = head;
- head = wert;
- if(foot == null){
- foot = wert;
- }
- }
- public void print(){
- System.out.print("Liste: [");
- print(head);
- System.out.println("]");
- }
- public void print(ListenElement wert){
- if (wert == null) return;
- System.out.print(wert.zahl + "->");
- if (wert.next != null){
- System.out.print(" ");
- print(wert.next);
- }
- }
- public static void main (String ... Args){
- Liste a = new Liste();
- Random rand = new Random();
- for(int i=0; i<40; i++){
- int n = rand.nextInt(100);
- a.insert(n);
- }
- a.print();
- }
- }
Add Comment
Please, Sign In to add comment