Is there any equivalent of python's sum()
in Java?
There's nothing built into the language. There are plenty of libraries that do things like that, though. Or write your own three-line routine. How you do it depends on how you are representing your elements (the usual suspects—for double values—being List<Double>
or double[]
).