• Post Reply Bookmark Topic Watch Topic
  • New Topic

1 to N parameters in a method  RSS feed

 
john ersan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'd like to ask how to implement 1 to n parameters in a method in java.

for eg.


in C# i was using params keyword and array of TextBox , but have no idea in Java ?

Can anyone help please ?

Thanx for ur Time..

Good Coding..
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this answers the right question:
Variable Length Arguments. That's in Java 5 or later, and really works out like an array.
[ January 09, 2006: Message edited by: Stan James ]
 
john ersan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
, i'm using j2sdk 1.4.2 , but i'm downloading 1.5 now.. 1.4.2 gives error

thanx for your time

good coding
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your intuition about using array was fine. It's a little fussier syntax than the new variable args, but common enough practice.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by john ersan:
, i'm using j2sdk 1.4.2 , but i'm downloading 1.5 now.. 1.4.2 gives error

thanx for your time

good coding


Variable arguments is a new feature to Java 1.5. Although as Stan points out, you can do something similar in Java 1.4 using an array.

Layne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!