Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

satck size in java

// Java code to illustrate size()
import java.util.*;
  
public class StackDemo {
    public static void main(String args[])
    {
        // Creating an empty Stack
        Stack<String> stack = new Stack<String>();
  
        // Use add() method to add elements into the Stack
        stack.add("Welcome");
        stack.add("To");
        stack.add("Geeks");
        stack.add("4");
        stack.add("Geeks");
  
        // Displaying the Stack
        System.out.println("Stack: " + stack);
  
        // Displaying the size of Stack
        System.out.println("The size is: " + stack.size());
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #satck #size #java
ADD COMMENT
Topic
Name
1+7 =