1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| public class Persion { private int id; private String name; private String phoneNumber; private String address; public Persion() { } public Persion setId(int id) { this.id = id; return this; } public Persion setName(String name) { this.name = name; return this; } public Persion setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } public Persion setAddress(String address) { this.address = address; return this; } public Persion printId() { System.out.println(this.id); return this; } public Persion printName() { System.out.println(this.name); return this; } public Persion printPhoneNumber() { System.out.println(this.phoneNumber); return this; } public Persion printAddress() { System.out.println(this.address); return this; } }
public class Test { public static void main(String[] args) { Persion persion1 = new Persion(); persion1.setId(3).setName("John") .setPhoneNumber("1111111").setAddress("US"); persion1.printId() .printName() .printPhoneNumber() .printAddress(); } }
|
若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏