public class Cat {
String name;
int age;
String gender;
Cat setName(String name) {
this.name = name;
return this;
}
Cat setAge(int age) {
this.age = age;
return this;
}
Cat setGender(String gender) {
this.gender = gender;
return this;
}
void show() {
System.out.println("Cat " + name + ", age " + age + ", gender " + gender);
}
public static void main(String[] args) {
Cat kitty = new Cat().setName("kitty").setAge(1).setGender("Male");
kitty.show();
}
}
Cat kitty, age 1, gender Male