Assalam O Alekum: i have problem in this keyword. public class MyClass{ public MyClass(){ this("hello); // why this keyword write the first line. SOP("thanks"); } public MyClass(String str){ SOP(str); } }
Originally posted by asif zia: Assalam O Alekum: i have problem in this keyword. public class MyClass{ public MyClass(){ this("hello); // why this keyword write the first line. this or super if used in the constructor should be the first line here we are calling the other constructor of the current class which takes a string as a parameter. (that is the constructor public MyClass(String str) hope it is clear SOP("thanks"); } public MyClass(String str){ SOP(str); } }