本帖最后由 xiaxiaqingyang 于 2010-01-21 20:14:15 编辑

解决方案 »

  1.   

    第一次发帖求助,请不要打击我!!
    为什么没有热心的人伸伸手?http://www.com128.com/face/com128%2F48%2F%C8˼%D2%C9%CB%D0%C4%C0%B2.JPG
      

  2.   


    public class Outer {
    int x = 10;
    Inner in = new Inner(); Inner doit(int n) {
    in.y = n;//在此处修改的in.y并不会影响下面的新生成的Inner()。
    return new Inner();//此处返回的new Inner()中y的值仍是10。
    } class Inner {
    int y = x;
    } public static void main(String[] args) {
    Outer out = new Outer();
    Outer.Inner in1 = out.doit(100);
    Outer.Inner in2 = out.new Inner();
    System.out.println("n1的y值是:" + in1.y);
    System.out.println("n2的y值是:" + in2.y);
    }
    } .
      

  3.   


    public class Outer {
    int x = 10;
    Inner in = new Inner(); Inner doit(int n) {
    // in.y = n;//在此处修改的in.y并不会影响下面的新生成的Inner()。
    // return new Inner();//此处返回的new Inner()中y的值仍是10。 Inner temp = new Inner();
    temp.y = n;
    return temp;
    } class Inner {
    int y = x;
    } public static void main(String[] args) {
    Outer out = new Outer();
    Outer.Inner in1 = out.doit(100);
    Outer.Inner in2 = out.new Inner();
    System.out.println("n1的y值是:" + in1.y);
    System.out.println("n2的y值是:" + in2.y);
    }
    }
    demo
      

  4.   

    因为 out.doit(100); 这个东西没有意义 你传100进去什么作用也没有