Martin Probst's weblog

Why is String.format() static?

Wednesday, January 16, 2008, 11:01 — 0 comments Edit

I really wonder why they made java.lang.String.format(String format, Object… args) a static method. Compare:

String message = String.format(“Failed to quizzle the fibble: %s”, fibble);
String message = “Failed to quizzle the fibble: %s”.format(fibble);

The latter isn’t only more object-oriented (static methods are in effect global procedures), it’s also less typing.

No comments.