-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionInterfaceDef.java
More file actions
44 lines (37 loc) · 1.17 KB
/
Copy pathFunctionInterfaceDef.java
File metadata and controls
44 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
*
*/
package com.java8.functionalInterface;
/**
* @author Atul Sharma
*
* https://github.com/sourac
*/
@FunctionalInterface
public interface FunctionInterfaceDef {
public void doSomething();
// public void doSomethingMore();
/*
* Functional interface can have max one abstract method.
*
* @functional interface annotation is provided for the compiler level error.
* even if we remove the @functionalInterface annotation and have only one
* abstract method, then also it is valid. Function interface also called the
* SAM(Single abstract method)
*
* In functional interface,we can define the deafult method now the default
* methods are not abstract, we can add as many we want.
*
* Now question comes, what if our functional interface has
* implemented/overriden the public method of the java.lang.object ?
*
* Well the answer to this is, that will still hold valid because, any
* implementation of the interface will have implementation from the
* java.lang.object or elsewhere.
*
*
*/
// f.ex if i override the toString() method from the object class, my functional interface will remain
// valid.
public String toString();
}