• Post Reply Bookmark Topic Watch Topic
  • New Topic

overloading -> cannot have different return type?  RSS feed

 
Anil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-->> "http://cse.spsu.edu/pfeibish/documents/Java%20Chapter%207%20pt%202.ppt#289,11,Overloading methods (pg 187)" <--

paste the link in the browser and see... says cant change return type!

same time... the below code is error free:

public class test{
public void setvar(int a, int b, int c)
{

}

private void setvar(int a, float b, int c){

}

protected void setvar( int a, int b , float c){

}
public int setvar( int a, int b, double c)
{
return a;

}

public int setvar(int ab, char c, int d){
return d;

}




}
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The method signature consists of the method name, the number (and order) of the arguments, and the data types of the arguments. The return type never comes into consideration.

If you look at the methods you list, they all have different data types.

Also, you may want to change your name to meet the JavaRanch name requirements before one of the Sheriffs blocks your ability to post...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!