Skip to content

Commit 17328e1

Browse files
authored
Create Covariant.java
1 parent 662b8ca commit 17328e1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Covariant.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class Covariant
2+
{
3+
Covariant get()
4+
{
5+
return this;
6+
}
7+
}
8+
9+
class Bag extends Covariant
10+
{
11+
Bag get()
12+
{
13+
return this;
14+
}
15+
void message()
16+
{
17+
System.out.println("This is covariant return type");
18+
}
19+
20+
public static void main(String args[])
21+
{
22+
new Bag().get().message();
23+
}
24+
}
25+

0 commit comments

Comments
 (0)