How to find the max element in int array with Java

1 Answer

0 votes
import java.util.*; 

public class MyClass {
    public static void main(String args[]) {
        Integer[] arr = {9, 1, 31, 12, 13, 3, 89, 100, 233, 4, 144, 99}; 
    
        Integer max = Collections.max(Arrays.asList(arr)); 

        System.out.println(max); 
    }
}


/*
run:

233

*/

 



answered May 24, 2019 by avibootz

Related questions

4 answers 346 views
1 answer 203 views
1 answer 270 views
1 answer 143 views
...