Java Beginner Programming Tutorial 27 Getters And Setters

preview_player
Показать описание
How to create getters and setters
Рекомендации по теме
Комментарии
Автор

EdwardLew .Lew is asking the same question I was about to type out. Are you nullifying the original assignment of printName by setting your own privateName? Is there any way to obtain the value "Beaver" without having to directly type it yourself?

VCepheus
Автор

edwardLew. With setters you can modify the variables and with getters you can catch them. Basically he jus modified the parameter.

grandorottcod
Автор

i believe it is because you set it to be "anthony" with the: public static void setPrivateName (String s) wich allows you to change the value of the private string to whatever you want it to be. and you change that with the t.setPrivateName ("whatever you want"). please someone correct me if im wrong. i just dont understand too well how the public static void setPrivateName (String s) { privateName=s } works. can someone explain that to me please?!

moutapt
Автор

why it came out "anthony" instead of "beaver"? that kind confusing me if we try to access private string but it's didn't run it out .

GodIsAGirl
Автор

Why didn't the word "Beaver" print out ?

sadaquekhan
Автор

can you please make the text a little bit much larger..

DanielBoakye
Автор

You dont even need the "set", the code runs just fine without it, this code has so many mistakes, its only confusing me more : / 

Nanoytgaming
Автор

Why is it bad coding practice to make stuff public?

MinMax
Автор

He made a mistake just to make it clear. He already declared privateName as "Beaver", but then he passed the string "anthony", changing the string value of s.

kakolasada
visit shbcf.ru