• Post Reply Bookmark Topic Watch Topic
  • New Topic

Infinite parameters  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know there is a way in c++ to have infinite parameters (can't remember what thats called), is there a way to do this is java as well?

What I'm trying to do is write a sorting algorithm to sort a table where the optional paramaters are the secondary, tertiarty... sort columns.

Thanks
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do "variable argument lists" in Java 5, aka JDK 1.5, aka "Tiger" -- the newest version of Java. Traditionally, you could only simulate this by using an array parameter. Since it's easy to define dynamic array objects in Java -- i.e.,



this isn't a terrible hardship.
[ January 31, 2005: Message edited by: Ernest Friedman-Hill ]
 
Jonathan Steel
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again.

I knew you could pass an array but figured there might be a better way. Im only using 1.4.2 so that will have to do, and that leads me into another question.

I'm a coop student working at a rather, extra large company and I was confused by the answer I got when I asked them why they arent using 1.5? Are there many differences in 1.5?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upgrading can be a pretty big deal, yes. This release represents the most fundamental changes to the language itself in many years -- since the 1.0 to 1.1 upgrade, really. Although it will run all your old code, it will complain bitterly if asked to compile it along with 1.5-specific code.

And with any big new Java release, there are unintentional incompatibilities -- it always seems that some app server or another simply refuses to work with the X.0 release. Then there's platform coverage; supports for platforms besides Solaris, Windows, and Linux tends to lag a bit. And finally, using new language features means (in many companies) training for developers, and that takes time.

So right now, many (most?) companies are still hanging back, getting ready, rather than upgrading everything whole-hog.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jonathan Steel:
I know there is a way in c++ to have infinite parameters (can't remember what thats called), is there a way to do this is java as well?

What I'm trying to do is write a sorting algorithm to sort a table where the optional paramaters are the secondary, tertiarty... sort columns.

Thanks


Technically, you cannot pass infinite parameters in any language since that would require infinite memory, which is only a theoretical contrivance for math classes like Theory of Computation. However, as Ernest pointed out above, you probably mean "variable argument list" since the number of arguments can change. Still, there are only finitely many arguments

Layne
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Layne Lund:

that would require infinite memory, which is only a theoretical contrivance


You obviously haven't done any work on the J2TME (Java 2, Turing Machine Edition) platform.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!