for question
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.
i used this answer
for (int i : list)
{
if (i > max)
{
max = i;
...
User Profile
Collapse
-
could you explain this loop please?
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.Leave a comment:
No activity results to display
Show More
Leave a comment: