mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-26 12:20:55 +07:00
13 lines
262 B
Java
13 lines
262 B
Java
// "Collapse loop with stream 'sum()'" "true-preview"
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
public class Matrix {
|
|
|
|
public double trace(final double[][] a) {
|
|
double sum = IntStream.range(0, a.length).mapToDouble(i -> a[i][i]).sum();
|
|
|
|
return sum;
|
|
}
|
|
}
|