M
Mark Space
I'm having trouble passing a single argument to String.format:
String damnit = String.format( locale, format,
new Object[]{input} );
This line chooses the String.format( String, Object... ) form of the
function, rather than the String.format( String, String, Object... )
form. Any ideas how to force to the latter?
The code below throws NPE because of the error, but even if I put
something in "locale" it won't work right, because it's treating locale
as the format string.
SSCCE:
package damnit;
public class damnit {
public static void main(String[] args) {
String locale = null;
String format = "%s";
String[] input = new String[]{"one", "two", "three", "four"};
for( int i = 0; i < input.length; i++ ) {
// throws NPE
String damnit = String.format( locale, format,
new Object[]{input} );
System.out.println( damnit );
}
}
}
String damnit = String.format( locale, format,
new Object[]{input} );
This line chooses the String.format( String, Object... ) form of the
function, rather than the String.format( String, String, Object... )
form. Any ideas how to force to the latter?
The code below throws NPE because of the error, but even if I put
something in "locale" it won't work right, because it's treating locale
as the format string.
SSCCE:
package damnit;
public class damnit {
public static void main(String[] args) {
String locale = null;
String format = "%s";
String[] input = new String[]{"one", "two", "three", "four"};
for( int i = 0; i < input.length; i++ ) {
// throws NPE
String damnit = String.format( locale, format,
new Object[]{input} );
System.out.println( damnit );
}
}
}