-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.java
More file actions
79 lines (56 loc) · 1.07 KB
/
A.java
File metadata and controls
79 lines (56 loc) · 1.07 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Anonymous Inner class example:-
*/
package javapep;
/**
*
* @author anil
*/
public interface A {//cannot create objects of interface
void meth();
}
interface B
{
void meth1();
}
abstract class C{
abstract void meth2();
void meth3()
{
System.out.println("hello meth3 abstract");
}
}
class test
{
public static void main(String args[])
{
A ob = new A()//Anonymous in a class it is only making a reference of interface A not creating object of A
{
public void meth()
{
System.out.println("Anonymous implementation");
}
};
B ob1 = new B()//Anonymous in a class it is only making a reference of interface A not creating object of A
{
public void meth1()
{
System.out.println("Anonymous implementation in Interface B");
}
};
B o2=()->{//lamba implementation it can be implemented with function interface only
//And function interface can only hold one methode
System.out.println("Lambda expressions");
};
o2.meth1();
test ob2 = new test(){
void meth2()
{
System.out.println("Abstract implementation");
}
};
ob.meth();
ob1.meth1();
//ob2.meth2();
}
}