Created
June 12, 2012 21:06
-
-
Save Romain-Geissler/2920140 to your computer and use it in GitHub Desktop.
Array og generics in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all:Test.class | |
test:all | |
java Test | |
%.class:%.java | |
javac '$<' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
public class Test{ | |
public static void main(String[] arguments){ | |
IntegerArrayList[] lists=new IntegerArrayList[2]; | |
lists[0]=new IntegerArrayList(); | |
lists[0].add(new Integer(42)); | |
lists[0].add(new Integer(53)); | |
lists[1]=new IntegerArrayList(); | |
lists[1].add(new Integer(420)); | |
lists[1].add(new Integer(530)); | |
for(IntegerArrayList list:lists){ | |
System.out.println("--------------------"); | |
for(Integer element:list){ | |
System.out.println(element); | |
} | |
System.out.println("--------------------"); | |
} | |
} | |
} | |
class IntegerArrayList extends ArrayList<Integer>{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment