Click here to watch in Youtube :
https://www.youtube.com/watch?v=YLOzRfP_HTM&list=UUhwKlOVR041tngjerWxVccw
OverloadDemo.java
Output
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); } }
nameArray = Peter name = Mr.Stephan
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:
No comments:
Post a Comment