File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes passing mutiple args to a method/constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "passing mutiple args to a method/constructor" Watch "passing mutiple args to a method/constructor" New topic
Author

passing mutiple args to a method/constructor

Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
Hi,

Is it ok to pass mutiple arguments to a method when they are not in the correct order?

[CODE]class a {
public a(int x, float y)
{//do stuff here}
}
class usinga{
a A = new a(3.2F, 7);
}
[CODE]


I'm a Hood Ornament
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3646
    
  15
Originally posted by Megs Maquito:

Is it ok to pass mutiple arguments to a method when they are not in the correct order?


No. They have to be in the order that the method is expecting them.


Joanne
Hentay Duke
Ranch Hand

Joined: Oct 27, 2004
Posts: 198
As Joanne said no you can't do that. But even more importantly, you could have easily found this out yourself with a simple little test program. It's a good habit to get into to test things yourself. There's no substitute for practice and experience.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
you have to send args in same order as the method was defined

same variable types too, but okay to use polymorphism

e.g. if method wants args Animal, Array of Cars

then you can pass: Dog, Array of Corollas

as dog is an animal, and corolla is a car, if you define their hierarchy as such
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
Thanks so much all!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing mutiple args to a method/constructor