Guest User

ReflectiveOperationException

a guest
May 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. public class Temp {
  2.     public static void main(String[] args) throws ReflectiveOperationException {
  3.  
  4.         class C {
  5.             public C(String a, String b, String... c) {
  6.             }
  7.         }
  8.  
  9.         C c1 = new C("a", "b", "c", "d");
  10.         java.lang.reflect.Constructor<C> constructor = C.class.getConstructor(String.class, String.class, String[].class);
  11.         C c2 = constructor.newInstance("a", "b", new String[]{"c", "d"});
  12.         C c3 = constructor.newInstance("a", "b", "c", "d"); // exception!!!
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment