【2018-10-15】【Diary】【FunctionInterface and Feel】

Today,The haze is back.so crazy and whole sky is grey.so  i m in bad mood.

The good news is i m always studing

>---------------so First is Java8 FuncionInterface.

1、it mean single abstract method interface.it has one abstract method compare with normal interface.相比于正常接口,它只有一个抽象方法。so this is the first character ,this is the main mean for this design.

2、you can use lamda decelop it.it will become easy and simple.

我认为一个抽象方法是它的核心,你可以使用简便的lamda表达式来实现接口。

3、if you have many abstract functions ,the compiler will give you error message.

如果你在此接口中写多个抽象方法,编译器将报错。

4、it allows you to have multiple normal methods and static methods.它允许你拥有多个正常实现的方法和静态方法.

5、All the same time,it allows you to define methods where it from Object that it is common.

并且它允许你定义object中的通用方法。

For Example

接口:
@FunctionalInterface
public static interface Converter<F, T> {
    T convert(F from);
}

实现:
Converter<String, Integer> integerConverter1 = (from) -> Integer.valueOf(from);
Integer converted1 = integerConverter1.convert("123");
System.out.println(converted1);   // result: 123

>>---------------In the java class you can define the generic(泛型) T,K..... Only do it for Object Head.在类初始做泛型,使用它

>>>---------------If you compare Objecet A  and Object B,you can implement Compareble Interface。如果你想比较多个对象的一个字段,你可以实现此接口去比较。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值