/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package jmylistbad; /** * * @author gabriele */ public class MyListBad { private ListElement head=null; public MyListBad(){}; public void insert(int v){ ListElement tmp = new ListElement(v,head); head = tmp; }; public int pop() { if (head == null) return 0; // se la lista e' vuota restituiamo // convenzionalmente il valore zero ListElement tmp = head; head = head.getNext(); int v = tmp.getValore(); return v; } public String toString(){ ListElement p = head; String s="("; while (p != null){ s=s + " " + p.getValore(); p=p.getNext(); }; return s+" )"; }; }