Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Stack/Java/stack-1.java
Normal file
21
Task/Stack/Java/stack-1.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import java.util.Stack;
|
||||
|
||||
public class StackTest {
|
||||
public static void main( final String[] args ) {
|
||||
final Stack<String> stack = new Stack<String>();
|
||||
|
||||
System.out.println( "New stack empty? " + stack.empty() );
|
||||
|
||||
stack.push( "There can be only one" );
|
||||
System.out.println( "Pushed stack empty? " + stack.empty() );
|
||||
System.out.println( "Popped single entry: " + stack.pop() );
|
||||
|
||||
stack.push( "First" );
|
||||
stack.push( "Second" );
|
||||
System.out.println( "Popped entry should be second: " + stack.pop() );
|
||||
|
||||
// Popping an empty stack will throw...
|
||||
stack.pop();
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue