首页 > 其他 > 详细

paip。java 高级特性 类默认方法,匿名方法+多方法连续调用, 常量类型

时间:2014-01-21 10:15:51      阅读:351      评论:0      收藏:0      [点我收藏+]
paip。java 高级特性 类默认方法,匿名方法+多方法连续调用, 常量类型

作者Attilax 艾龙,  EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax


/////6.1    常量类型

idx = "book.txt".find("txt")


    public static <T> T $(T t) {
             return t;

        }
        
        
/////////////////////多方法连续调用
new global().multiMethod1("aa").multiMethod2("22");

    public <T> global multiMethod1(T t)
    {
        System.out.println( " mtd1 ");
        return this;
        
    }
    public <T> global multiMethod2(T t)
    {
        System.out.println( " mtd2 ");
        return this;
        
    }
    
////////////    6.8    类默认方法,对象即函数,默认方法.

调用car.$("o1 13");
---------实现-------------
public static void $(String s)
    {    
         System.out.println("defalut method:"+ s);
        
    }
    
//////////////6.9    匿名方法(方法内部匿名类)
    
String c = new ccParser() {

            public String t() {
                return "haoa 012";
            }

        }.t();

paip。java 高级特性 类默认方法,匿名方法+多方法连续调用, 常量类型

原文:http://blog.csdn.net/attilax/article/details/18210477

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!