February 16, 2017

[HDGEM] How to call a constructor from another class in Java

public class Foo {      private int x;        public Foo() {          this(1);      }        public Foo(int x) {          this.x = x;      }  }
To chain to a particular superclass constructor instead of one in the same class, use superinstead of this
Note that you can only chain to one constructor, and it has to be the first statement in your constructor body.

Posted By Blogger to HDGEM at 2/16/2017 09:52:00 AM
Post a Comment

Featured Post

Updated Coupons / promo codes for Google Apps for Work / Business

To redeem: 1. Sign up for Google Apps   2. Go to your billing settings  3. Choose your payment plan  4. Enter your promo code ...