Quote:
|
Originally Posted by Eric the Red
Your solution Arevos worked
|
You're welcome. It's nice to know that a year spent working with Eclipse still has it's uses
Quote:
Originally Posted by titaniumdecoy
I would be more than happy if someone could explain to me why that code compiles under Java 5. According to Sun's documentation, the following is the correct way to call printf
|
Both ways work. Java 5 also introduced varargs, which are denoted by an ellipses (...) after the type. If you look at the type of the function:
public PrintWriter printf(String format, Object... args)
You'll notice that the end argument isn't a normal array. IIRC, you can use it in one of two ways. Like this:
System.out.printf("%s %s", new Object[] { "Hello", "World" }); Or like this:
System.out.printf("%s %s", "Hello", "World"); The two are equivalent; the second form is essentially just syntactic sugar for the first. Incidentally, C# has exactly the same functionality, which behaves in exactly the same way, but uses the keyword "params" instead.
Also, this type of string creation:
new String("Java is object oriented.") Is almost always wrong and bad. The only time it's of possible use is when dealing with small substrings of large strings. I can go into detail, if anyone's
really interested in the strange little nooks and crannies of Java.