Datasets:

ArXiv:
License:
File size: 1,305 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
package rd222dv_assign1.intCollection;

public class CollectionMain {

	public static void main(String[] args) {
		
		ArrayIntList list = new ArrayIntList();
		System.out.println("List: ");
		list.add(1);
		list.add(3);
		list.add(8);
		list.add(7);
		list.add(3);
		
		System.out.println(list);
		
		System.out.println("Index of 7 at pos: "+list.indexOf(7));
		
		list.addAt(9,2);
		
		System.out.println(list);
		
		System.out.println("List is empty: " + list.isEmpty());
		
		System.out.println("Index of 7 at pos: "+list.indexOf(7));
		
		list.remove(3);
		
		System.out.println("Remove int from index 3: "+list);
		
		ArrayIntStack stack = new ArrayIntStack();
		System.out.println("Stack: ");
		stack.push(1); // pushing elements to the stack
		stack.push(3);
		stack.push(8);

		// Peek at the top of the stack.
		System.out.println("Top of stack: " + stack.peek());

		// Pop the stack and display the result.
		System.out.println("Popping this element: " + stack.pop()); //?????????

		// Pop again.
		System.out.println("Popping this element: " + stack.pop());

		System.out.println("Stack Size: " + stack.size());
		
		System.out.println("Top of stack: " + stack.peek());
		
		System.out.println("Stack is empty: " + stack.isEmpty());
	}

}