Answer the question
In order to leave comments, you need to log in
I can't figure out how to use getters and setters?
I opened just one tab to study getters and setters, then I had to create a dozen more tabs in search of understandable information and explanations of a bunch of terms and commands from articles. Help me understand how getters and setters work.
Here for this example:
public class Cat {
private String name;
private int age;
private int weight;
public Cat(String name, int age, int weight) {
this.name = name;
this.age = age;
this.weight = weight;
}
public Cat() {
}
public void sayMeow() {
System.out.println("Мяу!");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
Answer the question
In order to leave comments, you need to log in
It's better to read the tutorial than to open tabs. There will be more sense.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question