Intro to Variable Arguments
What do you do if your method requires a variable number of variables?
Jeff Friesen has launched a new column called Java Tech with an article on Using Variable Arguments. Jeff continues to write a Java 101 column for JavaWorld magazine and has started his column for us with a look at some of Tiger's new features. What if you want to add a collection of numbers but you don't know how many will be in your collection? This is Jeff's first example.
static int sum (int ... numbers)
int total = 0;
for (int i = 0; i < numbers.length; i++)
total += numbers [i];
Now you can call this method as sum(10,20) or sum(18,20,305,4). There are certainly other ways to handle this particular case, but it is a nice illustration to draw you into the article. What are your thoughts on var args?
In today's Weblogs , Eduardo Pelegri-Llopart blogs about the Total Cost of Development and Developer Communities. He includes Training, Examples, Support, and Risk of choosing the right solution as contributors to TCD. He says that these costs "are very well addressed by developer communities. The example that I often use is Struts . I don't want to minimize the technical benefits of Struts, but I believe that the main reason why Struts is so succesful is the very strong developer community built around the code which help reduce the tocal cost of development by addressing the contributors I mention above."
Simon Brown has started a discussion on running "one-time set up and tear down logic" in his test classes in Global setUp() and tearDown() in JUnit tests. He uses a static initializer block with a shutdown hook for set up and tear down logic.
Although he is writing about JXTA in the specific, Mike Duigou's entry Evolution is an interesting look at what happens as you discover problems with an API. In his example he talks about the problems with adding a new public method to an API and references Fred Brooks' point that if you do a rewrite of your code "The users also won't be thrilled to have to rewrite their code to use the 2.0 release, there's the risk that the user base will fork between the 1.0 and 2.0 release. The user base of the product is growing though and new users will use only the new APIs."
Also in Java Today, Art Gould interviews Satya Kolachina on Linux Enterprise Application Development. Kolachina says that "The Java platform mitigates risks that I see with open source because it separates applicatin development from the underlying layer. There arent many Linux vendors providing tools and SDKs; they primarily provide distributions. The inventors of Java have really helped the Linux platform: there are a lot of IDEs and other tools available. So I believe that the survival and health of Linux is enhanced by Java platform."
Jason Briggs is helping those of you Migrating to Velocity. If you already have a JSP-based project, there is some pain in moving over to take advantage of Velocity. Jason helps you make the transition and provides the motivation for doing so, saying "Velocity is a simple, yet powerful, templating engine that can be used to generate dynamic content as an alternative to the incumbent standard. In some cases it provides a performance advantage over JSPs, and it certainly forces a web developer to think differently about separating content from code."
Take a tour of Sun Java Studio Enterprise in a free webinar on April 21st, 9am PDT. You will need to register for this Sun Developer Network event.
In today's java.net News Headlines
- HttpClient Becomes Jakarta Sub-Project
- Final Proposed Draft: JSR 105 - XML Digital Signature APIs
- JavaBlogs Rewritten
- JCE taglib and CryptoLib 1.0
- BayStar Capital to SCO: We Want Our Money Back
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using
our news submission
form. All submissions go through an editorial review by news director
Steve Mallet before being posted to the site. You can also subscribe to
News RSS feed.
Current and upcoming
- April 20-21 Sun Tech Days: Singapore
- April 23-25 New England Software Symposium
- April 28
Sun Java Studio Enterprise Moderated Chat
- April 30 - May 2 Twin Cities Software Symposium
- May 6-8 The ServerSide Java Symposium
- May 8 Kwarup do DFJUG
- May 10-14 JAX 2004
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.
Archives and Subscriptions: This blog is delivered weekdays as the
Today RSS feed. All java.net members can subscribe to the email
updates for the site at the href="https://java-net.dev.java.net/servlets/ProjectMailingListList">
java-net Mailing Lists page. You must be logged in to subscribe
to the javanet_Daily and javanet_Weekly lists. Also, once this page
is no longer featured as the front page of
java.net it will be archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.