- public class Person {
- private String name ;
- public void setName(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public class Outer{
-
- public void getMoney(){
- System.out.println(Person.this.getName()+"赚钱");
- }
-
- }
- class Inner{
- public void heart(){
- System.out.println(Person.this.getName()+"心脏良好");
- }
- public void liver(){
- System.out.println(Person.this.getName()+"肝脏不好请求治疗");
- }
- public void stomach(){
- System.out.println(Person.this.getName()+"胃良好");
- }
- }
- }
- public class Run {
- public static void main(String[] args) {
- Person p = new Person();
- p.setName("xx");
- Person.Outer ou = new Person().new Outer();
- ou.getMoney();
- Person.Inner in = new Person().new Inner();
- in.heart();
- in.liver();
- in.stomach();
- }
- }
复制代码
为什么这个name赋不上值啊?????
|
|