/*
- 2021/5/12/dome03
- */
@FunctionalInterface
interface IMath{
int add(int a,int b);
}
public class Circle{
public static void main(String[] args) {
IMath shili = ( a ,b) -> (a + b );
System.out.println(shili.add(1,2));
}
}
/*
- @ddate 2021/5/12/adome04
- */
interface IMyMessage<P,R>{
R int2srtring(P zhengshu);
}
//靜態(tài)方法的使用
public class Dome04 {
public static void main(String[] args) {
IMyMessage<Integer,String>shili=(zhengshu )-> zhengshu+"";
String str =shili.int2srtring(50000);
System.out.println(str.length());
}
}
/*
- @date2021/5/12/dome05
- */
@FunctionalInterface
interface IMyMessage1<R>{
R zhuandaxie();
}
public class Dome05 {
public static void main(String[] args) {
IMyMessage1<String>shili="hello"::toUpperCase;
System.out.println(shili.zhuandaxie());
}
}
/*
2021/5/12/demo06
-
*/
@FunctionalInterface
interface IMyMessage6<R,P>{
R compare (P p1 ,P p2);
}public class Dome06 {
public static void main(String[] args) {
//
IMyMessage6<Integer ,String> message6 = String::compareTo;
System.out.println(message6.compare("后" ,"要"));
}
}
/*
- 2021/5/12/demo07
- /
@FunctionalInterface
interface IMyPerson<R,PN,PA>{
R message(PN name ,PA age);
}
public class Demo07 {
public static void main(String[] args) {
//引用構(gòu)造方法
IMyPerson<Student ,String ,Integer> shili = Student::new;
System.out.println(shili.message("jackma",50));
}
}
。。熔吗。昧谊。尝偎。重归。国夜。减噪。。车吹。筹裕。
/ - 2021/5/12/demo07
- */
public class Student {
private String name;
public String getName() {
return name;
}
public Student(String name, int age) {
this.name = name;
this.age = age;
}
public int getAge() {
return age;
}
private int age ;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
}