Your constructor zad2
is creating another instance of zad2
here:
testMethodbt.invoke(new zad2(), "1");
That will call the same constructor on another instance, which will create its own new zad2()
, and so on, and this will continue until the stack overflows.
If you meant to invoke the method on the current instance, pass this
instead of a new zad2
.
This applies also to the earlier line in the constructor:
testMethod.invoke(new zad2(), 10, 10);
Of course it raises the question of why reflection is needed, when a straight method call would suffice here.