in JAVA by
Q:
What are the advantages of passing this into a method instead of the current class object itself?

▼ Show 1 Answer

0 votes
by

As we know, that this refers to the current class object, therefore, it must be similar to the current class object. However, there can be two main advantages of passing this into a method instead of the current class object.

this is a final variable. Therefore, this cannot be assigned to any new value whereas the current class object might not be final and can be changed.

this can be used in the synchronized block.

JAVA
Learn More with Madanswer

Related questions

0 votes
asked Nov 14, 2020 in JAVA by rajeshsharma
...