I got a two dimensional String array with only numbers in it;
System.out.println(Arrays.deepToString(temp));
[[1, 3, 1, 2], [2, 3, 2, 2], [5, 6, 7, 1], [3, 3, 1, 1]]
I need to check if the array contains only numbers, otherwise I will throw an exception.
System.out.println(Arrays.deepToString(temp[0]).matches("[0-9]*")); - return false
System.out.println(Arrays.deepToString(temp[0]).matches("[0-9]+")); - return false
As far as I get, The code says that the array does not contains only numbers, because when converted to char the array is like :
[[, [, 1, ,, , 3, ,, , 1, ,, , 2, ], ,, , [, 2, ,, , 3, ,, , 2, ,, , 2, ], ,, , [, 5, ,, , 6, ,, , 7, ,, , 1, ], ,, , [, 3, ,, , 3, ,, , 1, ,, , 1, ], ]]
How can I check if it contains only numbers?