Mike Firkser
Rutgers '84
Mike Firkser
Rutgers '84
Mike<br />SCJP 1.4<br />----------------------------<br />mdcleary@earthlink.net<br />----------------------------<br />There are 10 types of people<br />in the world. Those that <br />understand binary, and those<br />that don't.
Originally posted by Nicky Bodentien:
It would be replacing %s with Hello World. The s after % is for string. With C, when you called printf, you needed to tell it the number and types of its arguments in this way because they could be absolutely anything, and C programs did not have this information at runtime.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
For my latest books on Java, including Introducing JavaFX 8 Programming, see HerbSchildt.com
Originally posted by Warren Dew:
I'd like to see an example where one would need actually need varargs to handle something that could not otherwise be handled in Java.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Warren Dew:
Layne Lund:
I'd like to see an example where one would need actually need varargs to handle something that could not otherwise be handled in Java.
Originally posted by Jeff Walker:
I've been programming in Java for 6 years, and never once said to myself, "Hey, I wish I could pass in a variable number of arguments here!"
One more point, will
public static void main(String[] args) {}
now change to something like:
public static void main(String... args) {}
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Mike Firkser
Rutgers '84
Originally posted by Mike Rutgers:
Maybe I'm misunderstanding all of this, but it looks like using a vararg is the same thing as passing an array, or vector, or arraylist, etc. Is it somehow more efficient?
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Originally posted by Mike Rutgers:
Maybe I'm misunderstanding all of this, but it looks like using a vararg is the same thing as passing an array, or vector, or arraylist, etc. Is it somehow more efficient?
Originally posted by Stefan Wagner:
But Number (4) and type (String, String, int, float) of arguments are known at compile-time.
Can you pass in an array if you want? I'm not looking forward to
x = max(a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, t, s, u, v, w, x, y, z, aa, bb, ab);
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
42
Consider Paul's rocket mass heater. |