*
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 Android Security Essentials Live Lessons this week in the Android 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: 3432
    
  12
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: 2049
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!
 
 
subject: passing mutiple args to a method/constructor
 
Similar Threads
Mutiple File Uploading
mutiple annotaion in jsp page?
Mutiple instances of request handlers
doubt on mutiple inheritance
returning mutiple values