Advertisement
Guest User

Untitled

a guest
Jul 18th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public Item heaviestItem (){
  2.  
  3. if (itemList.isEmpty()) {
  4. return null;
  5. }
  6.  
  7. int auxWeight=0;
  8. String auxName="";
  9. Item auxItem= new Item(auxName, auxWeight);
  10.  
  11. for (Item item : itemList) {
  12. if (item.getWeight()> auxItem.getWeight()) {
  13. auxItem=new Item(item.getName(), item.getWeight());
  14. }
  15. }
  16. return auxItem;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement