标签:private package public return import
package com.ctgu.java; import javax.sound.midi.MidiDevice.Info; public class TestPerson { public static void main(String[] args) { Person p =new Person(); p.setAge(10); p.info(); p.setName("李雷"); p.info(); } } class Person{ private String name; private int age ; public Person(){ } public Person(String name){ this.name = name; } public Person(String n , int a){ name = n; age = a; } public void setName(String n){ name = n; } public String getName(){ return name; } public void setAge(int age){ this.age = age; } public int getAge(){ return age; } public void eat(){ System.out.println("人吃饭"); } public void sleep(){ System.out.println("人睡觉"); } public void info(){ System.out.println("name"+ name +"age:"+age); this.show(); } public void show(){ System.out.println("我是一个人:"+this.name); } }
标签:private package public return import
原文地址:http://9815936.blog.51cto.com/9805936/1605190