Advertisement
Guest User

Untitled

a guest
Jul 18th, 2025
23
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. int auxWeight=0;
  3. String auxName="";
  4.  
  5. if (itemList.isEmpty()) {
  6. return null;
  7. }
  8.  
  9. for (Item item : itemList) {
  10. if (item.getWeight()>auxWeight) {
  11. auxWeight=item.getWeight();
  12. auxName=item.getName();
  13. }
  14. }
  15.  
  16. Item auxItem = new Item(auxName, auxWeight);
  17. return auxItem;
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement