°íÃÄÁֽŵ¥·Î Çߴµ¥ °°Àº ¿¡·¯°¡..


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :°í°æȯ 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:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]