What is meaning of that code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is meaning of that code

public void set color(string c) { this.color=c; } }

19th Jun 2017, 6:42 AM
R Prathibha
R Prathibha - avatar
5 Answers
+ 6
it's used for giving control accessing to variable... it's only accessible by its public method and other can't access them
19th Jun 2017, 7:57 AM
Sweta Shaw
+ 4
it's a java setter method. whenever You call this method u hv to set value to ur variable mention inside method and it's easy way to assign value.
19th Jun 2017, 7:49 AM
Sweta Shaw
+ 1
That's a setter. To get a better understanding of setters and getters, read here: https://stackoverflow.com/a/2036991
19th Jun 2017, 6:53 AM
Jamie Isaksen
Jamie Isaksen - avatar
0
wy we have to use set and get method
19th Jun 2017, 7:50 AM
R Prathibha
R Prathibha - avatar
0
thanku
19th Jun 2017, 8:00 AM
R Prathibha
R Prathibha - avatar