blob: d6a9e3b9f4642cf4e49a1de171f90e960501ffdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
public class StackOfStrings {
private class Node {
String item;
Node next;
}
private Node first = null;
private int size = 0;
public boolean isEmpty() {
return first == null;
}
/*
public void STackOfStrings() {
}
*/
public void push(String item) {
Node oldfirst = first;
first = new Node();
first.item = item;
first.next = oldfirst;
size++;
}
public String pop() {
String i = first.item;
first = first.next;
size--;
return i;
}
public int size() {
return size;
}
}
|