import java.util.*;
public class Example {
private static final int SIZE = 100;
public static void main( String[] args ) {
List list = new ArrayList( SIZE );
for ( int i=0; i<=SIZE; i++ ) {
list.add( new Integer( i*i ) );
}
Integer x = list.getLast();
System.out.println( x.intValue() );
}
}知道错误就是不知道怎么该....
public class Example {
private static final int SIZE = 100;
public static void main( String[] args ) {
List list = new ArrayList( SIZE );
for ( int i=0; i<=SIZE; i++ ) {
list.add( new Integer( i*i ) );
}
Integer x = list.getLast();
System.out.println( x.intValue() );
}
}知道错误就是不知道怎么该....
public static void main( String[] args ) {
List list = new ArrayList( SIZE+1);
for ( int i=0; i<=SIZE; i++ ) {
list.add( new Integer( i*i ) );
}
Integer x = (Integer)list.get(SIZE);
System.out.println( x.intValue() );
}
楼主也太抠门了,居然不给分,不厚道