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:
40:
41:
42:
|
public class StackTest1
{
public static void main(String[] args)
{
Stack myStack = new Stack (1);
myStack.push(new Book("Kindheitstraum", "Horst Meier"));
System.out.println(myStack.array[0]);
}
}
class Stack
{
private int top = 0;
Book [] array;
int groesseStack=0;
public Stack (int groesseStack)
{
this.groesseStack = groesseStack;
}
public Book push (Book element)
{
return array[top++] = element;
}
}
class Book
{
private String titel;
private String author;
public Book (String titel, String author)
{
this.titel = titel;
this.author = author;
}
}
|