String[] array = new String[] {"1", "2", "3", "25"};
I want to find the maximum number inside that string and return it as an integer
.
What is the best way, especially with regards to performance as I have to parse a few million rows with it?
Two solutions I can think of:
Arrays.stream(array).mapToInt(Integer::parseInt).max().orElse(0);
Integer.valueOf(Collections.max(Arrays.asList(array))); //.max returns 0 when empty array