• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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: 805
  • 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...
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic