String Class static Method format
Lines 13–14 use static String
method format to return a String
containing a greeting with the user’s name. Method format
works like method System.out.printf
, except that format
returns the formatted String
rather than displaying it in a command window. Line 17 displays the greeting in a message dialog, just as we did in Fig. 3.12.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.