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());
            }
        }

    ******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************
  • 相关阅读:
    杂记:高僧的炒股境界
    在Windows 7中使用tsmmc远程桌面
    VS2010初体验
    code4fun: one service,one config
    WCF进阶:将编码后的字节流压缩传输
    有高手想换工作的么?
    code4fun:host wcf service just in time
    evey的几张鼠绘
    说说WCF Rest
    外包一类似联众room的项目
  • 原文地址:https://www.cnblogs.com/cloudLi/p/12868671.html
Copyright © 2011-2022 走看看