1//////////////////////// Phone.java
 2public class Phone{
 3
 4    private String name;
 5    private String realeseDate;
 6    private String companyName;
 7    private boolean isAndroid;
 8    private boolean isKoreaCompany;
 9
10    public static class Builder{
11
12        private String name;
13        private String realeseDate;
14        private String companyName;
15        private boolean isAndroid;
16        private boolean isKoreaCompany;
17
18        public Builder name(String name){
19            this.name = name;
20            return this;
21        }
22        public Builder realeseDate(String realeseDate){
23            this.realeseDate = realeseDate;
24            return this;
25        }
26        public Builder companyName(String companyName){
27            this.companyName = companyName;
28            return this;
29        }
30        public Builder isAndroid(boolean isAndroid){
31            this.isAndroid = isAndroid;
32            return this;
33        }
34        public Builder isKoreaCompany(boolean isKoreaCompany){
35            this.isKoreaCompany = isKoreaCompany;
36            return this;
37        }
38
39        public Phone buildInstance(){
40            return new Phone(this);
41        }
42
43    }
44
45    private Phone(Builder builder){
46        this.name = builder.name;
47        this.realeseDate = builder.realeseDate;
48        this.companyName = builder.companyName;
49        this.isAndroid = builder.isAndroid;
50        this.isKoreaCompany = builder.isKoreaCompany;
51    }
52
53    public String getName() {
54        return name;
55    }
56
57    public String getRealeseDate() {
58        return realeseDate;
59    }
60
61    public String getCompanyName() {
62        return companyName;
63    }
64
65    public boolean isAndroid() {
66        return isAndroid;
67    }
68
69    public boolean isKoreaCompany() {
70        return isKoreaCompany;
71    }
72}
73
74//////////////////////// Main.java
75public class Main {
76
77    public static void main(String[] args){
78
79        Phone iphone = new Phone.Builder()
80                .companyName("apple")
81                .name("Iphone13")
82                .isKoreaCompany(false)
83                .isAndroid(false)
84                .realeseDate("2021")
85                .buildInstance();
86
87        System.out.println("iphone.getName() = " + iphone.getName());
88        System.out.println("iphone.getCompanyName() = " + iphone.getCompanyName());
89
90    }
91}