• Post Reply Bookmark Topic Watch Topic
  • New Topic

can i change the return type in method overloading?  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author manish
*/
public class overloadtest {
public void add(int a,int b)
{

System.out.println(a+b);
}
public int add(int a,int b,int c)
{
return (a+b+c);
}
public static void main(String[] args) {
overloadtest ob=new overloadtest();
ob.add(5,6);
int c=ob.add(3,3, 4);
System.out.println(c);
}
}


in this program overloading perform or not
 
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, have you tried it? You have all the code there, what happened when you tried to compile and run it?

Sean
 
manish kr. pandey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for advise.

program is run well. and out put is-
11
10



 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!