Question
HOW DO I MODIFY THIS CODE WITHOUT USING THE LIBRARY ARRAYLIST??????? import java.io.*; import java.util.Scanner; import java.util.ArrayList; public class StackQueue{ public static void main(String[] args){
HOW DO I MODIFY THIS CODE WITHOUT USING THE LIBRARY "ARRAYLIST"???????
import java.io.*; import java.util.Scanner; import java.util.ArrayList;
public class StackQueue{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("1. Stack Operations"); System.out.println("2. Queue Operations"); System.out.print("Enter your choice: "); int mainChoice = sc.nextInt(); int stackChoice, queueChoice; ArrayList
public static void printStackMenu(){ System.out.println("********* Stack Operations *********"); System.out.println("1. Add element to stack - push"); System.out.println("2. Remove element from stack and return it - pop"); System.out.println("3. Return the top of the stack - top"); System.out.println("4. Print the elements of stack"); System.out.println("5. Print the size of stack"); System.out.println("6. EXIT"); System.out.print("Enter your choice: "); }
public static void printQueueMenu(){ System.out.println("********* Queue Operations *********"); System.out.println("1. Add element to queue - enqueue"); System.out.println("2. Remove element from queue and return it - dequeue"); System.out.println("3. Return the front of the stack - first"); System.out.println("4. Print the elements of queue"); System.out.println("5. Print the size of queue"); System.out.println("6. EXIT"); System.out.print("Enter your choice: "); }
public static void doStackOperations(ArrayList
public static void doQueueOperations(ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started