標籤: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;
}
};
}
}