I interrupt these practical questions with a philosophical one:
I am coming up to speed on Java 1.5 and I find code using java.util.Scanner and System.out.printf incredibly easier to write and read compared to the convoluted formatting and parsing techniques required by earlier versions of Java.
Since format strings were around since C (really since FORTRAN), why do you think it took so long for Java to add these features?
Well, printf depends on varargs and autoboxing, and Scanner relies on regular expressions (and they still had to make substantial changes to the regex package to support it). But you're right: they could have added those features long ago if they had wanted to. I think they just didn't want to corrupt their clean-syntaxed, statically-typed language. Both features effectively introduce dynamic typing by using a syntax that looks like line noise.
For the printf-like function, how they work in 1.5, you need the ellipse (...) and autoboxing.
Adding an rarely used ellipse-feature, only for formatting perhaps seemed not economical, when designing the language. I can imagine a solution with Object  instead of ellipse, and don't have a quick answer, why not to use it. Perhaps because of intensive usage of reflection, which would have been needed, to implement it. And perhaps in the beginning of Java, everybody expected the commandline to vanish in the haze: Windows promised to make everything right with win95, Linux was a small flower in the corner, java didn't konquer the servermarket, and logging was rarely needed.
Today we see, that windows will never be a stable system, and the linux-folk loves the commandline. Logging, intensively done on servers, uses a CLI too. So the need for printf is more stable than thought.
Bjarne S. invented (?) cout << for c++ to get rid of printf ("%i", 7); -- with not much luck too. I liked the << operator much more than old printf-functions, but got in touch to outputstreams very early and had to learn both at about the same time.
Another try to explain the history: The language C is getting out. (ouh - flamewars!) And the programers have to learn Java now.
But they know every trick about printf, and claimed loudly to want it in java. And the nice people at sun answered: Ok, here you got it!
But there are other formatting-possibilities, we could live with for a long time.
[ September 26, 2004: Message edited by: Stefan Wagner ] [ September 26, 2004: Message edited by: Stefan Wagner ]
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
Think of its history. It was not originally used to teach programming fundamentals. Today, with the popularity in CS1 and APCS the language has had to "simplify" itself. I/O and formatting were good choices in simplification.
Also, as mentioned, going back to C roots.
Still, C# has, I think, a good way for I/O and formatting. Looks like it learned its lesson from Java mistakes.
Mike, email me. We will have a possible position opening again in Spring 05- if you are still interested in teaching.