Hey, im a really noob at this, but I need some help with this question. I've got to complete this in order to progress to my second year although im not doing programming and will not need it in the second year. The question is as follows:

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.

To be honest I dont really have a clue what how to write this so any help would be much appreciated. Cheers guys

Recommended Answers

All 4 Replies

You won't need much of anything in second year if you don't pay attention in class and pass the one's required in first year.

Perhaps you should take a look at the "Starting Java" FAQ stickied at the top of this forum if you have no relevant class materials to refer to.

You did a whole year of programming and no one taught you the simple algorithm for looping and finding the max number?

while (list.hasNext()){
System.out.println("been lazy? :P");
}

I do hope you know the logic in finding a max of a number, eh?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.