Wednesday, 17 February 2016

Java Tutorial : Java Overloading methods(Different return types)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=YLOzRfP_HTM&list=UUhwKlOVR041tngjerWxVccw

OverloadDemo.java
/*
 * Example of overloaded method with different return types. 
 */
public class OverloadDemo
{
    public char[] getName()
    {
        char[] nameArray =
        { 'P', 'e', 't', 'e', 'r' };
        return nameArray;
    }

    public String getName(String name)
    {
        return "Mr." + name;
    }

    public static void main(String[] args)
    {
        OverloadDemo overloadDemoObj = new OverloadDemo();

        char[] nameArray = overloadDemoObj.getName();
        System.out.println("nameArray = " + new String(nameArray));

        String name = overloadDemoObj.getName("Stephan");
        System.out.println("name = " + name);

    }
}
Output
nameArray = Peter
name = Mr.Stephan
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/OverloadDemo_Different_ReturnTypes_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OverloadDemo_Different_ReturnTypes_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6d0a162e56a976d5453743136b5d5af40909f335/BasicJava/OverloadDemo_Different_ReturnTypes_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment