### First steps with functional programming in Java 8: reduce on lists of integers

I've been writing solutions to many of Adrian Neumann's problems in Java, listed here, when I decided to look into whether or not Java has functional abilities. It turns out they've been introduced to Java 8 over the past several years, and unlike Python, they're not quite as succinct. Here I'll only post a few simple examples (my first), but I can already tell they're still composed of Java's verbosity.

To work with Java 8 I installed Eclipse Neon, which I already like better than Eclipse Luna (which I had been using previously in my computer science class). It also has a dark mode, which I'm a huge fan of. I still use Sublime Text's monokai syntax theme, however.

For the most part I'll compare and contrast the Python equivalent to the Java I've written. I'm not nearly as competent in Java as I am Python, but I'd like to become far better at software development. I'm interested in increasing my productivity, and maybe someday I'll actually have a job programming in industry, who knows.

With any further ado, here's some straightforward Python that generates a random list and finds the max entry, as well as the entire list's product, using reduce. Of course, Python has the built in function max covering the former operation, but it's totally possible to implement the same algorithm.
#! /usr/bin/env python3.4
# -*- coding: utf-8 -*-

""" Generate a random array and perform some functional operations upon it """

from random import randint
from array import array
from functools import reduce

LENGTH = 10

def construct(length: int =10) -> array:
""" Construct a random array of unsigned integers """
return array('I', (randint(1, length + 1) for _ in range(length)))

def getMax(arr: array =array('I', [])) -> int:
""" Determine the maximum entry in the array """
return reduce(lambda x, y: x if (x >= y) else y, arr)

def getMul(arr: array =array('I', [])) -> int:
""" Get the product of an entire array """
return reduce(lambda x, y: x * y, arr)

if __name__ == '__main__':
arr = construct(LENGTH)
print("Maximum of random array: " + str(getMax(arr)))
print("Multiplied random array: " + str(getMul(arr)))

[By the way, I've recently downloaded the PyCharm IDE and my initial experience has been quite positive.] The inner workings of these functions should be pretty straightforward.

On the other hand, writing it in Java is not quite as intuitive (at least, ! IMHO).
import java.util.ArrayList;
import java.lang.Math;      // apply this to the list with reduce()

public class FunctionalTest {

public Integer getMax(ArrayList A) {
// find the largest element of the list w/lambda function reduce()
return A.stream().reduce(0, Math::max);
}

public Integer getMul(ArrayList A) {
// multiply all the entries in the ArrayList
return A.stream().reduce(1, Math::multiplyExact);
}

}

This ::'' syntax is strange, and I only recall seeing it in C++ or PHP. I also noticed that the reduce method takes two arguments, viz. an identity element in addition to a function upon which to act on the stream. To quote the Oracle docs,
The identity element is both the initial value of the reduction and the default result if there are no elements in the stream.
In this specific case the identity on the set of integers under addition is 0, and under multiplication, 1.

This is only a comparison of reduce, but the other methods, filter and map, are similar, and I look forward to writing posts about java.util.function in the future as I continue to explore Java.