Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Test{
- public static void main(String[] args){
- ArrayList<Misc> aList = new ArrayList<Misc>();
- for (int i = 0; i < 10; i++){
- aList.add(new Misc1(i));
- }
- for (int i = 0; i < 10; i++){
- aList.add(new Misc(i));
- }
- for (int i = 0; i < aList.size(); i++){
- System.out.println(aList.get(i).out());
- }
- }
- }
- class Misc{
- String str;
- public Misc(int i){
- this.str = "meow"+i;
- }
- public String out(){
- return this.str;
- }
- }
- class Misc1 extends Misc{
- public Misc1(int i){
- super(i);
- this.str = "woof"+i;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement