Return maximum or minimum value of an array
public int min(int... args) {
int min = args[0];
for (int i = 1; i < args.length; i++) {
min = Integer.min(min, args[i]);
}
return min;
}
public int max(int... args) {
int max = args[0];
for (int i = 1; i < args.length; i++) {
max = Integer.max(max, args[i]);
}
return max;
}
Written by Bruno Candido Volpato da Cunha
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Java
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#