thieumao

Create multi object with 1 class

Sep 20th, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package multiobj;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class MultiObj {
  6.  
  7.     /**
  8.      * @param args the command line arguments
  9.      */
  10.     public static void main(String[] args) {
  11.         // TODO code application logic here
  12.         ArrayList<B> arrB = new ArrayList<B>();
  13.         B objB = new B();
  14.         int sll = 3;
  15.         for (int i = 0; i < sll; i++){
  16.             arrB.add(objB);
  17.         }
  18.        
  19.     }
  20.    
  21.  
  22.    
  23. }
  24.  
  25. class A{}
  26.    
  27. class B extends A{
  28.     B(){}
  29. }
Advertisement
Add Comment
Please, Sign In to add comment