Home arrow static arrow Java Programming [Archive] - Method arguments
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Method arguments
This topic has 5 replies on 1 page.

Posts:13
Registered: 8/9/04
Method arguments  
Aug 9, 2004 7:44 AM



 
What is the maximum number of parameters that can be passed through a function in java. Does it depend on the type of the function used??

thankz in advance

Arun
 

Posts:105
Registered: 6/8/04
Re: Method arguments  
Aug 9, 2004 7:51 AM (reply 1 of 5)



 
Well, I don't know of any specific limit... frankly, if you're planning to pass in so many parameters that this might be a problem (10+), you probably should re-think your design regardless of whether it would work.
 

Posts:24,036
Registered: 2/3/03
Re: Method arguments  
Aug 9, 2004 7:55 AM (reply 2 of 5)



 
Excellent point, RiOrius.

Worrying about the number or args a method can take is a symptom of impending design smell...
 

Posts:458
Registered: 7/1/03
Re: Method arguments  
Aug 9, 2004 8:02 AM (reply 3 of 5)



 
What is the maximum number of parameters that can be
passed through a function in java. Does it depend on
the type of the function used??

thankz in advance

Arun

There probably is. However, passing a lot of parameters is not a very good idea. You might try passing a collection, array or a container object (An object created just to pass the 12 fields in a form) instead. Usually passing more than 10 parameters is a sign that something is broken with your design.
 

Posts:11,186
Registered: 06.04.04
Re: Method arguments  
Aug 9, 2004 8:06 AM (reply 4 of 5)



 
Worrying about the number or args a method can take is a symptom of impending design smell...

I may have overlooked something, but AFAICT my copy of the JLS doesn't mention any restriction on
the number of method parameters, so I guess it will be some silly number like 2^31-1or so ...

And I thought 4 was a lot ...

kind regards,

Jos
 

Posts:3,258
Registered: 00-08-28
Re: Method arguments  
Aug 9, 2004 8:50 AM (reply 5 of 5)



 
What is the maximum number of parameters that can be
passed through a function in java. Does it depend on
the type of the function used??

thankz in advance

Arun

Well even if you get the answer to this one, how about if one or many of these parameters are collections or arrays which in turn are carrying a no. of objects/parameters which in turn again so it might well be a recursive process.

 
This topic has 5 replies on 1 page.