저는 1 차원 배열의 정수를 가진 ArrayList ArrayList<int[]>
을 가지고 있습니다. 내가 디버깅하고 내 시계 아래의 코드에서 tmp
에 설정 한 경우Java에서 정수 배열을 재정의 할 수 있습니까?
, 나는 int[]
의 toString
메소드를 오버라이드 (override) 할 필요가 의미하는 tmp
의 내용을 볼 수 있도록하려면?
현재로서는 아래의 print
방법을 사용하여 내용을 인쇄하여 볼 수 있습니다. 그러나 이상적으로하고 싶지 않고 tmp
의 내용을보고 싶습니다. 디버거의 멤버입니다.
PS : 나는 tmp.get(0)[0]
등
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] + " ");
}
}
정수로 상자 int 경우, 그것은 클래스 형식의 개체가 될 것 같아요, 당신도 toString을 얻을 것 같아요 ... – ultrajohn
코드에 주석 당신이 콘솔에 인쇄하는 것을 의미합니다, 하지만 귀하의 질문은 당신이 그것을 표시하는 디버거를 원하는 의미합니다. 무엇 이니? 그리고 어떤 IDE를 사용하고 있습니까? – shmosel
질문 제목에 대한 답변에서 대답은 아니오입니다. – shmosel