Welcome to the Ranch
You should always use
code tags, which I have added to your code, and you can see how much better it looks
Unfortunately it highlights the fact that your indentation is inconsistent, which makes the code much more difficult for you to read. Also you should use {} after
if etc. For the same reason. Your variable names are not very good; you have a class called classes (should be C not c) which handles collections, and which you are calling num.
I can’t see anything wrong with the way you are passing your List, assuming that max() method takes a List<Integer> as a parameter. What you have done wrong, hoever, is
Put too much code in a static setting, orTried inappropriately to use an instance field.I think the first error is likelier to be true.
I prefer to initialise all instance fields in the constructor (I know some people will disagree with me), so you need to write a constructor. I also don’t like break; (again some people will disagree), so I would move the != 0
test into the loop continuation condition. Unfortunately that means writing the reading statement twice.
I presume you know about boxing and unboxing, and about declaring a List<XXX> rather than ArrayList?