Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to to use covariant return type in java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 265
    Comment on it

     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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: