Modify the following Shelf class so it becomesa Generic class where String class can be replaced with anyclass.
Public class Shelf{
private String[] items;
private int capacity, itemsNumber = 0;
private String mainItem;
public Shelf(int capacity){
items = (String[]) new String [capacity];
}
public void add (String item){
if (!item.equals(mainItem))
items[itemsNumber++] = item;
}
public String getFirst() {return items[0];}
public int getCapcity() {return capacity;}
}
Expert Answer
An answer will be send to you shortly. . . . .