Type2: Can not hold many type of element
Closed this issue · 0 comments
GuroKung commented
From code: create stack by StackFactory.makeStack(2);
Stack stack = getStack(2);
assertTrue(stack.isEmpty());
stack.push("Hi");
assertEquals("Hi", stack.peek());
stack.push("just push it");
assertEquals("just push it", stack.peek());
stack.push(123);
System.out.print("Top Stack: "+stack.peek());
assertEquals(123,stack.peek());
it shows that when we create it, the stack is empty and we can push element in it.
after the test. We can push more than one element in it and peek result is correct.
but when we try to push another type of element in to the stack it's turns out that
it doesn't add in to the stack.
Actual value:
Top Stack: just push it
Expected value:
Top Stack: 123