How do I create a new list that contains multiple integers? thanks!
A line of code would also be greatly apreciated.


1 2 3 4 5 6 7 | int [] integerArray = new int [ 5 ]; // an empty array that could store 5 ints int [] anotherArray = new int []{ 1 , 2 , 10 , 42 }; // an array with 4 specified elements // example usage: integerArray[ 0 ] = 5 * 7 ; integerArray[ 1 ] = 2 *integerArray[ 0 ]; integerArray[ 2 ] = 10 -anotherArray[ 2 ]; |
1 2 3 4 5 | List<Integer> integerList = new ArrayList<Integer>(); // example usage: integerList.add( 5 ); // if I'm correct, the 5 will automatically be 'interpreted' as new Integer(5) integerList.add( 99 ); int firstValue = integerList.get( 0 ).intValue(); |
1 2 | import java.util.List; import java.util.ArrayList; |