If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

help with overloading code

Can anyone help me with overloading. I have a task that starts with 2 numbers being entered by the user. then it increases to three numbers entered then 4 . how can I get the user input then have the program automatically figure the average of the numbers entered. Please help

Re: help with overloading code

I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S(from: bash.org.ru)//always looking for job opportunities in AU/NZ/US/CA/Europe :PwillCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL")); USE [code] TAGS!Read this FAQ if you are new here. If this post was helpful, please rate it!

Then you can call the average() method with 2, 3 or 4 integer arguments and always get a double as the result.
There comes a point where this gets excessive (e.g. with 5, 6, 7 or more integer arguments) - then it would be worth considering either using varargs (as suggested in the previous post) or passing the arguments as an array of integers.