zoukankan      html  css  js  c++  java
  • 面向对象--封装

    package com.test;
    //封装
        public class test_2 {
            public static void main(String[] args) {
                animal a = new animal();
                a.setAge(18);
                a.setName("zhangsan");
                a.test();
            }
        }


        class animal{
            private String name;
            private int age;
            public void setName(String name) {
                this.name = name;
            }
            public void setAge(int age) {
                this.age = age;
            }

            public int getAge() {
                return this.age;
            }
            public String getName() {
                return this.name;
            }
            public void test() {
                System.out.println(getName() +getAge());
            }
        }

    ******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************
  • 相关阅读:
    自动布局
    初探 iOS8 中的 Size Class
    iOS数据安全性问题
    iOS应用程序之间的跳转
    iOS 关于xml解析的问题
    iOS中的一些基础知识点
    关于iOS项目中使用ZBarSDK
    iOS中关于google地图的用法
    基于4.5Framework web程序、SQLSERVER数据库打包
    docker私有仓库搭建
  • 原文地址:https://www.cnblogs.com/cloudLi/p/12868671.html
Copyright © 2011-2022 走看看