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

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();

原文地址:https://www.cnblogs.com/attilax/p/5964092.html