Hello,
Consider the method declaration:
String.format(String, Object ...)
The Object ...
argument is just a reference to an array of Object
s. Is there a way to use this method with a reference to an actual Object
array? If I pass in an Object
array to the ...
argument - will the resultant argument value be a two-dimensional array - because an Object[]
is itself an Object
:
Object[] params = ....; // Make the array (for example based on user-input)
String s = String.format("%S has %.2f euros", params);
So the first component of the array (Who is used in the String.format
method), will be an array and he will generate:
[class.getName() + "@" + Integer.toHexString(hashCode())] has
and then an error because the array size is 1.
I hope I have explained well. Maybe much grammar faults (14 years old and Dutch speaking), so forgive me.
The bold sequence is real question.
This is a second question: Does a ...
array/parameter have a name?