Collection and sharing of, interview questions and answers asked in various interviews, faqs and articles.....
Java :Call one constructor from another?
Yes, by using this() syntax. E.g.
public class1(int id) { this.id = id; // “this” means this object public class1 (int id, String type) { this(id); // calls constructor public class1(int id) this.type = type; // ”this” means this object
No comments:
Post a Comment