Java 8 ???????????
???????????? ???????[ 2015/5/22 15:42:41 ] ???????????????
???????????????Java???c++???????????Java????ж?????????? ???Java???????????(extends)???????? ??????????(implements)??????????????????г????????????????????о????????????????з????????????
??????Щ????????????????????Java 8?????? ????????????巽????(default method)?? ??????????????????????
????????????????? ???????е????????Java???????????μ????? ????????Щ????????????? ???磬 ?????Collection?????
????????default Stream<E> stream()?? ?????Set??List??????????????????????????? ????????????????copy?????????
?????????????????????????????????Java????????е????? ????????? ???????н??? ???????????????? ?????е??????????????????????????? ????????????????? ??????????????????У? ?????????????Java???е????
????????ж???????
????????????????Interface A?? Interface B?? Interface C?? ??й?????£?
????+---------------+ +------------+
????| Interface A | |Interface B |
????+-----------^---+ +---^--------+
????| |
????| |
????| |
????+-+------------+--+
????| Interface C|
????+------------+
????A??B?????????????????default String say(String name)?? ??????C???override????????? ?????????
????interface A {
????default String say(String name) {
????return "hello " + name;
????}
????}
????interface B {
????default String say(String name) {
????return "hi " + name;
????}
????}
????interface C extends A??B{
????}
?????????????
????C:Lambdasrc>javac -J-Duser.country=US comcolobulambdachap
????ter3MultipleInheritance1.java
????comcolobulambdachapter3MultipleInheritance1.java:17: error: interface C inherits unrelated defaults for say(String) from types A and B
????static interface C extends A??B{
????^
????1 error
?????????????????C?и???override????????? ????????????????
????interface C extends A??B{
????default String say(String name) {
????return "greet " + name;
????}
????}
?????????????????????????????? ??????????????????????????????????????????????????????????A??B????????????? C????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11