JDK8新特性☞Function測試

/**
 * JDK8新特性☞Function接口測試 Function接口有一個參數並且返回一個結果,並附帶一些和其他函數組合的默認方法
 * 
 * @author Administrator
 *
 */
public class Test1 {
public static void main(String[] args) {
Function<Integer, String> function = String::valueOf;
Function<Integer, Integer> then = function.andThen(Integer::valueOf);
Integer apply = then.apply(123);
System.out.println(apply);
}

}

測試結果


123

發佈了66 篇原創文章 · 獲贊 1 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章