zoukankan      html  css  js  c++  java
  • 3

    封装
        1.隐藏类内部实现细节(封装)
    
        2.步骤:
                    a.将属性私有化(private)
             b.提供getter/setter 方法(getXxx(),setXxx())
             c.在getter/setter中加入控制语句
        3.this 关键词:
            this:表示当前对象
            调用属性:this.属性名
            调用方法:this.方法名();
            this():表示调用构造函数。
            注意:this();必需写在构造函数的第一行。       
    
    public class Excelle {
        private String type;
        private String id;
        public Excelle(){
            
        }
        public Excelle(String id,String type){
            this.type=type;
            this.id=id;
        }
        public String getType(){
            return type;
        }
        public String getId(){
            return id;
        }
    }
    View Code
    public class Regal {
        private String type;
        private String id;
        public Regal(){
            
        }
        public Regal(String id,String type){
            this.type=type;
            this.id=id;
        }
        public String getType(){
            return type;
        }
        public String getId(){
            return id;
        }
    }
    View Code
  • 相关阅读:
    EVM靶机渗透
    Joomla漏洞复现
    渗透测试
    Kali软件库认识
    谷歌hack语法
    Metasploit学习
    sqli-labs less-17
    sqli-labs(less-11-16)
    sqli-labs (less-8-less-10)
    less-7
  • 原文地址:https://www.cnblogs.com/wojiatingting/p/7015652.html
Copyright © 2011-2022 走看看