内置类与静态内置类——T2220

package 对象及变量的并发访问2;

/**
 * 内置类与静态内置类。
 */
class PublicClassT2220{
      private String username;
     private String password;

     class PrivateClass{
        private String age;
        private String address;

        public String getAge() {
            return age;
        }

        public void setAge(String age){
            this.age=age;
        }

        public String getAddress(){
            return address;
        }

        public void setAddress(String address){
            this.address=address;
        }

        public void printPublicProperty(){
            System.out.println(username+" "+password);
        }
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

class RunT2220{
public void  RunT2202(){
    PublicClassT2220 publicClassT2220=new PublicClassT2220();
    publicClassT2220.setUsername("username");
    publicClassT2220.setPassword("password");

    System.out.println(publicClassT2220.getUsername()+" "+publicClassT2220.getPassword());

    PublicClassT2220.PrivateClass privateClass=publicClassT2220.new PrivateClass();
    privateClass.setAge("ageValue");
    privateClass.setAddress("addressValue");

    System.out.println(privateClass.getAge()+" "+privateClass.getAddress());
}
}
public class T2220 {
    public static void main(String[] args) {
        RunT2220 runT2220 =new RunT2220();
    }
}

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页