Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1.  
  2. public class Main {
  3.     public int param;
  4.  
  5.     public static void main(String[] args) {
  6.         try {
  7.             Main a = Main.class.getConstructor().newInstance();
  8.             System.out.println("finished, param = " + a.param);
  9.         } catch (Exception ex) {
  10.             System.out.println("exception thrown");
  11.         }
  12.     }
  13.  
  14.     public Main() {
  15.         this(-1);
  16.         System.out.println("constr default");
  17.     }
  18.  
  19.     public Main(int param) {
  20.         System.out.println("constr param = " + param);
  21.         this.param = param;
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement