This time we have the following StockItem class which has three fields: String name, double pricePerUnit, and int quantity.
class StockItem {
private String name;
private double pricePerUnit;
private int quantity;
public StockItem(String name, double pricePerUnit, int quantity) {
this.name = name;
this.pricePerUnit = pricePerUnit;
this.quantity = quantity;
}
@Override
public String toString() {
return name + ": " + pricePerUnit + ", " + quantity + ";";
}
// getters
}
Write a method that accepts a list of StockItem objects, sorts them by their total value in descending order, and returns the sorted list. You don't need to read or write anything from or to the console, just implement the method.