I'm doing some practice questions and cant seem to work out these collection probelms think i need to use iterator or a while loop but cant seem to get them to work - dont really know how i'd go about getting the highest value in the collection any help would be appreciated, even just learning from the answers would be a lot of help.. cheers - see below
[1] Given a list of integers and an integer variable declared like this:
List<Integer> list;
int max;
and assuming that some values have been added to the list, write a loop which finds the largest value in list and stores it in max.
[2] A bank account is stored as a Map which maps the names of the account holders to a value representing the current balance of their account:
Map<String,Inte ger> bank;
Given a String variable declared like this:
String rich = null;
write a loop which will store the name of the person with the most money in their account in rich.
[3] Using the same bank account as in the previous question, and a list of strings:
Map<String,Inte ger> bank;
List<String> names;
write a loop which fills the list names with the names of all account holders whose accounts are overdrawn, i.e. the balance of their account is less than zero.
[1] Given a list of integers and an integer variable declared like this:
List<Integer> list;
int max;
and assuming that some values have been added to the list, write a loop which finds the largest value in list and stores it in max.
[2] A bank account is stored as a Map which maps the names of the account holders to a value representing the current balance of their account:
Map<String,Inte ger> bank;
Given a String variable declared like this:
String rich = null;
write a loop which will store the name of the person with the most money in their account in rich.
[3] Using the same bank account as in the previous question, and a list of strings:
Map<String,Inte ger> bank;
List<String> names;
write a loop which fills the list names with the names of all account holders whose accounts are overdrawn, i.e. the balance of their account is less than zero.
Comment