How to delete a value in array of objects using java

haruman_09 1 Reputation point
2022-12-26T02:41:11.857+00:00

I have to add a person's data and delete a person's data using array of objects that will have the output like this:

First Name:
Middle Name:
Last Name:

Press 1 if you want to add a person's data
Press 2 if you want to delete a person's data

then the entered data will be displayed and the user can choose which data they want to delete but i'm still stuck in the part on how to delete a certain data.

package igiveup;  
  
import java.util.*;  
  
public class Main {  
  
	public static void main(String[] args) {  
		// TODO Auto-generated method stub  
			  
			Employee employee [] = new Employee[3];  
			  
			for(int i = 0; i < employee.length; i++) {  
				  
				Scanner s = new Scanner (System.in);  
				  
				System.out.print("\nFirst Name: ");  
				String fname = s.nextLine();  
				  
				System.out.print("Middle Name: ");  
				String mname = s.nextLine();  
				  
				System.out.print("Last Name: ");  
				String lname = s.nextLine();  
				  
				System.out.print("Job Title: ");  
				String jobTitle = s.nextLine();	  
				  
				/*System.out.print("Press 1 if you want to add a person");  
				System.out.print("\nPress 2 if you want to remove a person");  
				int add = s.nextInt();  
				int del = s.nextInt();*/  
				  
Community Center | Not monitored
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.