• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

overloading -> cannot have different return type?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;

}




}
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic