Biblioteca Java - Blame information for rev 2
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mihai | 1 | package colectii.liste; |
2 | import java.util.*; | ||
3 | /** | ||
4 | * Exemplificare utilizare colectie LinkedList. | ||
5 | */ | ||
6 | public class LinkedExample { | ||
7 | public static void main(String[] args) { | ||
8 | LinkedList lk = new LinkedList(); | ||
9 | lk.addFirst(new Command("comanda 1")); | ||
10 | lk.addFirst(new Command("comanda 2")); | ||
11 | lk.addFirst(new Command("comanda 3")); | ||
12 | |||
13 | Command c = (Command)lk.removeLast(); | ||
14 | c.execute(); | ||
15 | c = (Command)lk.removeLast(); | ||
16 | c.execute(); | ||
17 | c = (Command)lk.removeLast(); | ||
18 | c.execute(); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | class Command{ | ||
23 | String name; | ||
24 | Command(String n){name = n;} | ||
25 | void execute(){System.out.println("Execute command:"+name);} | ||
26 | } |