Code: Select all
public void outputText(PrintWriter pw, String text) {
pw.printf(text).print("success");
}
Is it the case that with only 1 string passed in, the JVM considers the string already formatted?
Moderator: admin
Code: Select all
public void outputText(PrintWriter pw, String text) {
pw.printf(text).print("success");
}
For anyone here after 2025, the reason why no NPE is thrown as stated above is because not passing varargs argugment means varargs = empty array, not null.RoyEL1 wrote: ↑Tue Jun 14, 2016 11:49 amI find it a bit curious w.r.t.
that the execution works, but the Java Platform Standard Ed. 8 (JDK SE8) Documentation states that for a PrintWriter, the printf(String format, Objects ... arg) and the printf(Locale l, String format, Objects ... arg) both state that it will throw a NullPointerException if the format string is null.Code: Select all
public void outputText(PrintWriter pw, String text) { pw.printf(text).print("success"); }
Is it the case that with only 1 string passed in, the JVM considers the string already formatted?
Users browsing this forum: No registered users and 194 guests