Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Item heaviestItem (){
- if (itemList.isEmpty()) {
- return null;
- }
- int auxWeight=0;
- String auxName="";
- Item auxItem= new Item(auxName, auxWeight);
- for (Item item : itemList) {
- if (item.getWeight()> auxItem.getWeight()) {
- auxItem=new Item(item.getName(), item.getWeight());
- }
- }
- return auxItem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement