Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Test{
  4.     public static void main(String[] args){
  5.     ArrayList<Misc> aList = new ArrayList<Misc>();
  6.         for (int i = 0; i < 10; i++){
  7.             aList.add(new Misc1(i));
  8.         }
  9.         for (int i = 0; i < 10; i++){
  10.             aList.add(new Misc(i));
  11.         }
  12.  
  13.         for (int i = 0; i < aList.size(); i++){
  14.             System.out.println(aList.get(i).out());
  15.         }
  16.     }
  17.  
  18. }
  19.  
  20. class Misc{
  21.     String str;
  22.  
  23.     public Misc(int i){
  24.         this.str = "meow"+i;
  25.     }
  26.  
  27.     public String out(){
  28.         return this.str;
  29.     }
  30. }
  31.  
  32. class Misc1 extends Misc{
  33.     public Misc1(int i){
  34.         super(i);
  35.         this.str = "woof"+i;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement