public class Test {
public static void main(String[] args) {
//带空参,无返回值,不用lambda
A a = new A() {
//实现接口
@Override
public void NoReturn() {
System.out.println("你好世界!");
}
};
// a.NoReturn();
// a.doOther();
// a.doSome("hello world!");
//带空参,无返回值,使用lambda
A a1 = ()-> System.out.println("你好世界!");
a1.NoReturn();
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
//带空参,有返回值
//带一个参,有返回值
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带空参,1返回值,不用lambda
A a = new A() {
@Override
public void oneReturn(String str) {
System.out.println("str:"+str);
}
};
a.oneReturn("传入Str");
//带空参,1返回值,使用lambda
A a1 = str -> System.out.println("str: "+str);
a1.oneReturn("str传入");
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
void oneReturn(String str);
//带多个参,无返回值
//带空参,有返回值
//带一个参,有返回值
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带多个参,无返回值
A aa = (a,b,c)-> System.out.println(a+b+c);
aa.multiArgsAndNoReturn("a",1,2);
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
void multiArgsAndNoReturn(String a,int b,long c);
//带空参,有返回值
//带一个参,有返回值
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带空参,有返回值
A a = ()-> 100;
System.out.println(a.NoReturn());
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
//void multiArgsAndNoReturn(String a,int b,long c);
//带空参,有返回值
Object NoReturn();
//带一个参,有返回值
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带空参,有返回值
A a = ()-> 100;
System.out.println(a.NoReturn());
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
//void multiArgsAndNoReturn(String a,int b,long c);
//带空参,有返回值
Object NoReturn();
//带一个参,有返回值
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带一个参,有返回值
A a = (i)-> i*100;
System.out.println(a.oneReturn(321));
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
//void multiArgsAndNoReturn(String a,int b,long c);
//带空参,有返回值
//Object NoReturn();
//带一个参,有返回值
int oneReturn(int i);
//带多个参,有返回值
}
public class Test {
public static void main(String[] args) {
//带多个参,有返回值
A a = (i,j,k)->i*j*k;
long l = a.multiReturn((short) 1, 2, 3l);
System.out.println(l);
}
}
interface A {
default void doSome(String name) {
System.out.println("doSome name:"+name);
}
default void doOther(){
System.out.println("doOther");
}
//带空参,无返回值
//void NoReturn();
//带一个参,无返回值
//void oneReturn(String str);
//带多个参,无返回值
//void multiArgsAndNoReturn(String a,int b,long c);
//带空参,有返回值
//Object NoReturn();
//带一个参,有返回值
//int oneReturn(int i);
//带多个参,有返回值
long multiReturn(short i,int j,long k);
}