Course Solutions Uncategorized (Solved) : Modify Following Shelf Class Becomes Generic Class String Class Replaced Class Public Clas Q28059161 . . . .

(Solved) : Modify Following Shelf Class Becomes Generic Class String Class Replaced Class Public Clas Q28059161 . . . .

 

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. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Determine Focal Length Whether Erect Inverted Object 6cm Divergent Lens 36cm Convergent Le Q32603565 . . . .(Solved) : Determine Focal Length Whether Erect Inverted Object 6cm Divergent Lens 36cm Convergent Le Q32603565 . . . .

Determine the focal length and whether it is erect orinverted?Object=6cmDivergent lens=36cmConvergent lens=56cmScreen=66cm<br/><img src="https://media.cheggcdn.com/media%2Ff30%2Ff3050976-ec2f-478b-876e-653884b67260%2Fimage.png" alt="0o 8" aria-describedby="d3f"/>0o 8 Show transcribed image text Expert Answer Answer to Determine the focal length