how to write a function to reduce array in java code example Example: java reduce array Arrays.stream(array).reduce((str1, str2) -> str1 + str2);