Program to insert, remove elements from array

Problem statement

Program to insert, remove elements from array according to instruction

In this java program, we are taking 3 types of input from user like “insert” or “remove” or “exit”.

  • If user entered “insert”, take again input as element of array from user.
  • If user entered “remove”, take input as index of array from user.
  • If user entered “exit”, print output and exit from program.

 
 
Output

In above program, we took 3 types of input from user. If the input is “insert” then we added element into array. If the user entered “remove” then element at index should be removed from array. If input is “exit” exit from console and print final array.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.