What is different b/w "this" variable and "this()" function ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is different b/w "this" variable and "this()" function ???

can anyone help me to understand

2nd Apr 2018, 10:44 AM
Arun Tomar
Arun Tomar - avatar
9 Answers
+ 2
the first one (this) is used when you want to call the same variable. like this.variable the second one (this()) is a method or is a function.
2nd Apr 2018, 8:12 PM
Himmatullah Ferozee
Himmatullah Ferozee - avatar
+ 2
this is a keyword in Java. It can be used inside the Method or constructor of Class. It(this) works as a reference to the current Object whose Method or constructor is being invoked. The this keyword can be used to refer to any member of the current object from within an instance Method or a constructor
2nd Apr 2018, 8:17 PM
Himmatullah Ferozee
Himmatullah Ferozee - avatar
+ 2
yes, I will help you in your question Arun Tomar
2nd Apr 2018, 8:19 PM
Himmatullah Ferozee
Himmatullah Ferozee - avatar
+ 2
just check the below link you will understand the use of this in Java: https://www.guru99.com/java-this-keyword.html
2nd Apr 2018, 8:29 PM
Himmatullah Ferozee
Himmatullah Ferozee - avatar
+ 1
The first one is just a string while the second one is a method The first can just be printed but the second can be executed, invoked or called.
2nd Apr 2018, 11:38 AM
Vihaan Sejwani
+ 1
Can anyone explain me also
2nd Apr 2018, 5:22 PM
Arun Tomar
Arun Tomar - avatar
+ 1
Thanks I need it.. can u also solve my code problem.. I really appreciate it
2nd Apr 2018, 8:15 PM
Arun Tomar
Arun Tomar - avatar
+ 1
according to me.. and i know... we cant run keyword by apply (.).. i hope you understand.. what i try to say
2nd Apr 2018, 8:29 PM
Arun Tomar
Arun Tomar - avatar
+ 1
Thanks bro.. I understand what u try to say.. i appreciate to you
2nd Apr 2018, 8:33 PM
Arun Tomar
Arun Tomar - avatar