Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package Problem07_ImmutableList;
  2.  
  3. import com.sun.org.apache.bcel.internal.classfile.ClassFormatException;
  4. import java.lang.reflect.Field;
  5. import java.lang.reflect.Method;
  6. import java.util.List;
  7.  
  8. public class ImmutableListProblem {
  9.     public static void main(String[] args) {
  10.         Class listClass = ImmutableList.class;
  11.         Field[] fields = listClass.getDeclaredFields();
  12.         if (fields.length < 1) {
  13.             throw new ClassFormatException();
  14.         }
  15.  
  16.         Method method = listClass.getDeclaredMethods()[0];
  17.         System.out.println(method.getReturnType().getSimpleName());
  18.  
  19.  
  20.     }
  21. }
  22.  
  23. class ImmutableList{
  24.     private List<Integer> collection;
  25.  
  26.     public ImmutableList(List<Integer> collection) {
  27.         this.collection = collection;
  28.     }
  29.  
  30.     public ImmutableList getCollection() {
  31.         return new ImmutableList(this.collection);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement