java进阶--嵌套类和接口

public class third {
  
	private int id1;//私有成员
    public int id2;
	public static class class_top{
	    void sayid(third th){//静态嵌套类想要訪问顶层类的私有/公有成员仅仅能通过传递引用对象
	    	th.id1=12;
	    	th.id2=12;
	    }
	}
	public static class static_class extends class_top{
   
	static	void say_id(third th){
		    th.id1=12;		
		}
	
	}
	public class public_test{
		void sayid(){
			id1=12;//内部类和静态嵌套类不同 属于类实现的一部分所以能够直接訪问顶层类的成员
			id2=11;
		}
	}
	
	 public static void main(String atgs[])
		{
		 System.out.print(456);
		 test classTest=new test();
		  
	}

	

}

   
原文地址:https://www.cnblogs.com/wgwyanfs/p/7007553.html