Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Implementing the Stack Class in java list

import java.util.*;

class Main {

    public static void main(String[] args) {
        // Creating list using the Stack class
        List<String> list = new Stack<>();

        // Add elements to the list
        list.add("Apple");  
        list.add("Mango");  
        list.add("Banana");  

        System.out.println("List: " + list);

        // Access element from the list
        String str = list.get(1);
        System.out.println("Accessed Element: " + str+"
");

        // Remove element from the list
        String removedstr = list.remove(1);
        System.out.println("Removed Element: " + removedstr);
    }
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Implementing #Stack #Class #java #list
ADD COMMENT
Topic
Name
4+1 =