고쳐주신데로 했는데 같은 에러가..


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :고경환 1998년 5월 14일 09:33:54

In Reply to: [답변] 증가 연산자 사용에 문제가... posted by 김필호 on 1998년 5월 13일 20:10:33:

고쳐주신데로 증가 연산자를 고쳐서 사용했는데 nullpointer exception이
발생합니다.이상...


import java.util.*;


class VectorTest


{ public static void main(String[] args)


{ Vector[] v1 = new Vector[10];


for(int i = 0; i < v1.length; i++)


{


v1[i].addElement( new Integer(1)); //error(nullpointer exception)


v1[i].addElement( new Integer(2));//error(nullpointer exception)


v1[i].addElement( new Integer(3));//error(nullpointer exception)


int sum = 0;


for(int n = 0; n < v1[i].size(); n++)


sum += ((Integer) v1[i].elementAt(n)).intValue();


System.out.println( sum ); // 6


}


}


}


다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]