Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hard define in code a matrix Integer[][]

Question is simple for an expert

Integer[][] res= new Integer[][] {.....hard code some values here on 2 dim...}

How to return here 2 rows and 3 cols like this

1 2 3
4 5 6
like image 416
Pentium10 Avatar asked May 20 '10 18:05

Pentium10


2 Answers

int[][] res = {{1,2,3},
               {4,5,6}};
like image 138
Yuval Adam Avatar answered Oct 20 '22 06:10

Yuval Adam


This should work. (But I am no java expert).

Integer [][] ints = { {1, 2, 3}, {4, 5, 6} };
like image 45
nc3b Avatar answered Oct 20 '22 04:10

nc3b