0

Java - Difference between

What is the difference between this.setColor("Red") and this.setColor ="Red" ; ???

4th Jul 2021, 3:34 PM
kushal
2 Réponses
+ 3
Hi, kushal . this.setColor("Red") seems like a method of a current class taking one string argument called "Red" . What about this.setColor = "Red"; you are defining variable of a current class and setting in the string value "Red". This is the main difference. First one is the method, and second one is the variable.
4th Jul 2021, 4:34 PM
Maksat Ramazanov
Maksat Ramazanov - avatar
+ 3
This is a method: this.setColor("Red"); This is a atributte of class: this.setColor="Red";
5th Jul 2021, 2:12 AM
Cmurio
Cmurio - avatar