Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prova;
- import java.util.Iterator;
- import java.util.LinkedList;
- public class Prova{
- static int counter = 4;
- private int value = 2;
- public Prova() {
- value = ++counter;
- }
- public String toString(){
- return this.getClass().getName()+value+" ";
- }
- public void finalize(){
- System.out.println("F"+value);
- }
- }
- class G extends Prova{
- public static void main(String[] args) {
- LinkedList<Prova> x = new LinkedList<Prova>();
- Prova a1 = new G();
- G a2 = new G();
- Prova a3 = new Prova();
- x.add(a1); x.add(a3);
- a1 = null; a2 = null; a3 = null;
- Iterator<Prova> it = x.iterator();
- while(it.hasNext()){
- System.out.print(it.next());
- }
- System.gc(); System.runFinalization();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement