标签:des style blog http color io ar 2014
package innerclass;
/*
 * 方法中的内部类,
 * 1:非匿名内部类
 * 2:匿名内部类
 */
public class Parcel5 {
	//方法中的内部类,非匿名内部类
	public Destination destination(String s){
		class PDestination implements Destination{
			private String label;
			@Override
			public String readLable() {
				// TODO Auto-generated method stub
				return label;
			}
			
			public PDestination(String s){
				this.label = s;
			}
		}
		return new PDestination("XX");
	}
	
	//匿名内部类
	public Contens contens(){
		//匿名内部类
		return new Contens(){
			private int i = 1;
			@Override
			public int value() {
				// TODO Auto-generated method stub
				return i;
			}
		};
//		class PContens implements Contens {
//			private int i = 1;
//			@Override
//			public int value() {
//				// TODO Auto-generated method stub
//				return i;
//			}
//			
//		}
	}
//匿名的内部类引用外部的参数的时候,外部的参数一定要是final类型的
	public Destination destinationFinal(final String s){
		return new Destination(){
			//private String lable;
			@Override
			public String readLable() {
				return s;
			}
		};
	}
}
CA]TV]ES0BP_KLA)6.jpg)

标签:des style blog http color io ar 2014
原文地址:http://www.cnblogs.com/working/p/3919860.html