I have came across a java code in which I have seen passing this as a parameter of constructor? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have came across a java code in which I have seen passing this as a parameter of constructor?

What actually this referencing? Like Class Ray{ Smit s = new Smit(this); }

18th Aug 2019, 4:23 PM
Smit Kalkani
Smit Kalkani - avatar
4 Answers
+ 2
Is it true that if I want to create obj of Smit class from another class that another class must extends Smit class? For working of Smit(this) signature constructor?
18th Aug 2019, 6:25 PM
Smit Kalkani
Smit Kalkani - avatar
+ 1
I know that but passing in this way means what exactly this is referencing here?
18th Aug 2019, 5:14 PM
Smit Kalkani
Smit Kalkani - avatar
+ 1
Can you check one code for me please?
18th Aug 2019, 6:23 PM
Smit Kalkani
Smit Kalkani - avatar
18th Aug 2019, 6:23 PM
Smit Kalkani
Smit Kalkani - avatar