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); } }
sona gold
Ranch Hand
Joined: Feb 14, 2001
Posts: 234
posted
0
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); } }
sona<br />SCJP
Ravindra Mohan
Ranch Hand
Joined: Mar 16, 2001
Posts: 216
posted
0
Hi Asif, The keyword this is used here because it calls the constructor marked '2' please see my code below.
Hope this clarifies the issue. Ravindra Mohan.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.