In the below example I will help you to use covariant return type in java. In covariant return will used overriding method. The covariant return type specifies the return type in the same direction as the subclass. Here in the below example I have used two class Evon and Wipro. The return type of the get() method of Evon class is Evon but the return type of get() method of Wipro class is Wipro. You can see below program it will clearly describe you how to to use covariant return type in java.
class Evon{
Evon get(){retun this;}
}
Class Wipro extend Evon{
Wipro get(){retun this;
}
void message()
{
System.out.println("Welcome developer's");
}
public static void main(String args[]){
new Wipro.get().message();
}
}
Output:"Welcome developer's"
0 Comment(s)