I have an ArrayList ArrayList<int[]> which has one-dimensional array of integers as it's members.
When I am debugging and have my watch set on tmp from the code below, I want to be able to see tmp's contents, which means I have to override the toString method of int[]?
At the moment, I am able to see my contents by printing them out using the print method below. However, I do not want to do that ideally, and would like to see the contents of tmp and it's members from the debugger.
PS : I do not want to have debug watch expressions like, say, tmp.get(0)[0] etc
public class TryPrinting {
public static void main( String[] args ) {
int[][] people = { {7,0}, {7,1}, {6,1}, {5,0}, {5,2}, {4,4} };
TryPrinting obj = new TryPrinting();
obj.test( people );
}
public void test( int[][] people)
{
int n = people.length;
ArrayList<int[]> tmp = new ArrayList<>();
for (int i = 0; i < n; i++)
{
tmp.add(people[i][1], new int[]{people[i][0], people[i][1]});
print( tmp );//This works
System.out.println( tmp );//But I want this to work
System.out.println( "" );
}
}
/* print al */
public void print( ArrayList<int[]> al )
{
for(int i = 0;i<al.size();i++)
{
print( al.get( i ) );
}
System.out.println( "" );
}
/* print 1d array */
public void print(int[] a)
{
for(int i = 0;i<a.length;i++)
System.out.print( a[i] + " " );
}
}