다양한 객체를 포함할 수 있는 가변 길이 배열 Vector를 생성하고 활용하는 문제입니다 이를 해결하는 다음 프로그램에 대해 빈칸을 채우세요
공간크기 3, 총원소개수 3, (0) first (1) second (2) third
공간크기 6, 총원소개수 5, (0) cut in line (1) first (2) second (3) third (4) null 새치기 발생
공간크기 6, 총원소개수 3, (0) second (1) third (2) null
공간크기 6, 총원소개수 0, 빈 벡터
코드 빈칸 채우기
.;
public class VectorUsage
{
public static void print( <> list ) {
( "공간크기 " + list.() + ", 총원소개수 " + list.() + "," );
( int i = 0; i < list.(); i )
( " (" + i + ") " + list.(i) );
( list.() )
( " 빈 벡터" );
( list.( "cut in line" ) )
( " 새치기 발생" );
System.out.println();
}
public static void main( String[] args ) {
<> list = <>( 3 );
list.( "first " );
list.( "second" );
list.( "third " );
print( list );
list.( 0, "cut in line" );
list.( 4, null );
print( list );
list.( 0 );
list.( 0 );
print( list );
list.();
print( list );
}
}