una_maquina 35 Share Posted December 13, 2020 I know that I can just read up on the docs or find the answer by myself, but I'll learn far more if someone explains it in their own words -- and you'll also deepen your understanding by teaching. So I don't quite yet get it what this.variable = class.variable; is. Link to comment Share on other sites More sharing options...
Neffarion 485 Share Posted December 13, 2020 "this" just refers to a "variable" that is the reference of the current object, you can also use "this()" to use the current object constructor Honestly this is basic java, its better you just google search this. https://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html Link to comment Share on other sites More sharing options...
yeeter 520 Share Posted December 13, 2020 Here is a guide I link a lot of people concerning "this". Really big fan of Geeks For Geeks guides. https://www.geeksforgeeks.org/this-reference-in-java/ Link to comment Share on other sites More sharing options...
una_maquina 35 Author Share Posted December 13, 2020 7 hours ago, Neffarion said: "this" just refers to a "variable" that is the reference of the current object, you can also use "this()" to use the current object constructor Honestly this is basic java, its better you just google search this. https://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html 4 hours ago, yeeter01 said: Here is a guide I link a lot of people concerning "this". Really big fan of Geeks For Geeks guides. https://www.geeksforgeeks.org/this-reference-in-java/ Thanks guys, from what I understand now it's a way to update the global variable that you initiated in the class; like int i; It's done not to confuse the compiler. public void test(int i){ this.i = i; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.