Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

push function in java

// Java Code to illustrate push() Method
 
import java.util.*;
 
// Main class
public class StackDemo {
 
    // Main driver method
    public static void main(String args[])
    {
        // Creating an empty Stack
        Stack& lt;
        String& gt;
        STACK = new Stack& lt;
        String& gt;
        ();
 
        // Adding elements into the stack
        // using push() method
        STACK.push(" Welcome & quot;);
        STACK.push(" To & quot;);
        STACK.push(" Geeks & quot;);
        STACK.push(" For & quot;);
        STACK.push(" Geeks & quot;);
 
        // Displaying the Stack
        System.out.println(" Initial Stack
                           : "
                           + STACK);
 
        // Pushing elements into the stack
        STACK.push(" Hello & quot;);
        STACK.push(" World & quot;);
 
        // Displaying the final Stack
        System.out.println(" Final Stack
                           : "
                           + STACK);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #push #function #java
ADD COMMENT
Topic
Name
2+8 =