I have one problem with my code, I made an example program for displaying emp details from a linked list, now the problem when I try to delete a specific record means that it does not work, I hope I made some mistake in my code could you suggest how to do this?
import java.util.*; class EmpDedup { int record; String fprint; int fid; EmpDedup(int record, String fprint, int fid) { this.record = record; this.fprint = fprint; this.fid = fid; } public int getRecord() { return record; } public String getFprint() { return fprint; } public int getFid() { return fid; } public static void main(String[] args) { int count = 0; LinkedList<EmpDedup> list = new LinkedList<EmpDedup>(); list.add(new EmpDedup(101, "entry1", 20)); list.add(new EmpDedup(102, "entry2", 30)); list.add(new EmpDedup(103, "entry3", 40)); list.add(new EmpDedup(104, "entry4", 50)); Scanner input = new Scanner(System.in); System.out.print("Enter record no to display: "); int rec = input.nextInt(); for (EmpDedup data : list) { if (data.getRecord() == rec) { System.out.println(data.getRecord() + "\t" + data.getFprint() + "\t" + data.getFid() + "\t"); count++; } } System.out.println("The size of an linkedlist is: \t" + list.size()); System.out.println("The number of available record is :" + count); System.out.println("The size of an linkedlist is: \t" + list.size()); Scanner input1 = new Scanner(System.in); System.out.print("Enter record no to delete: ");
source share