初始化矩阵最简单的方法是什么?
// something like this would be nice
int[][] matrix = new int[][]{{1,2,3},{4,5,6},{7,8,9}};
最佳答案
如果你想定义变量类型,使用这个:
int[][] matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
如果变量是无类型的,使用这个:
def matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] as int[][]
关于groovy - 在常规中初始化矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4994012/