0% found this document useful (0 votes)
4 views

Java Lab Programs (49) Functional Interface

Uploaded by

vinol30054
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Java Lab Programs (49) Functional Interface

Uploaded by

vinol30054
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Functional Interface in Java

• Functional Interface in Java is also called Single Abstract Method (SAM) Interface.
• From Java8 onwards, to represent the instance of functional interfaces, lambda
expressions are used. It is a new feature in Java, which helps to achieve functional
programming approach.
• Lambda expressions are anonymous (don’t have names) shortcode blocks that can
take parameters and return a value just like methods.

interface rcat interface rcat


{ {
void javaclass(String stu); void javaclass(String stu);
} }

class abc implements rcat class abc implements rcat


{ {
public void javaclass(String stu) public void javaclass(String stu)
{ {
System.out.println(stu); System.out.println(stu);
} }

public static void main(String a[]) public static void main(String a[])
{ {
abc a1=new abc(); abc a1=new abc();
a1.javaclass("Java SE11"); a1.javaclass("Java SE11");

} rcat r1=new abc();


} r1.javaclass("Oracle Certified");

}
}
@FunctionalInterface @FunctionalInterface
interface rcat interface rcat
{ {
void javaclass(String stu); void javaclass(String stu);
} void javaquiz(String a);
}
class abc implements rcat
{ class abc implements rcat
public void javaclass(String stu) {
{ public void javaclass(String stu)
System.out.println(stu); {
} System.out.println(stu);
}
public static void main(String a[])
{ public static void main(String a[])
abc a1=new abc(); {
a1.javaclass("Java SE11"); abc a1=new abc();
a1.javaclass("Java SE11");
rcat r1=new abc();
r1.javaclass("Oracle Certified"); rcat r1=new abc();
r1.javaclass("Oracle Certified");
}
} }
}

You might also like