src/java.base/share/classes/java/util/Formattable.java
Print this page
rev 11411 : 8073347: javadoc of Formattable messed up by JDK-8019857
Summary: Change sample code formatting to the currently blessed idiom.
Reviewed-by: XXX
@@ -34,11 +34,11 @@
* control for formatting arbitrary objects.
*
* For example, the following class prints out different representations of a
* stock's name depending on the flags and length constraints:
*
- * {@code
+ * <pre> {@code
* import java.nio.CharBuffer;
* import java.util.Formatter;
* import java.util.Formattable;
* import java.util.Locale;
* import static java.util.FormattableFlags.*;
@@ -87,26 +87,26 @@
*
* public String toString() {
* return String.format("%s - %s", symbol, companyName);
* }
* }
- * }
+ * }}</pre>
*
* <p> When used in conjunction with the {@link java.util.Formatter}, the above
* class produces the following output for various format strings.
*
- * {@code
+ * <pre> {@code
* Formatter fmt = new Formatter();
* StockName sn = new StockName("HUGE", "Huge Fruit, Inc.",
* "Fruit Titanesque, Inc.");
* fmt.format("%s", sn); // -> "Huge Fruit, Inc."
* fmt.format("%s", sn.toString()); // -> "HUGE - Huge Fruit, Inc."
* fmt.format("%#s", sn); // -> "HUGE"
* fmt.format("%-10.8s", sn); // -> "HUGE "
* fmt.format("%.12s", sn); // -> "Huge Fruit,*"
* fmt.format(Locale.FRANCE, "%25s", sn); // -> " Fruit Titanesque, Inc."
- * }
+ * }</pre>
*
* <p> Formattables are not necessarily safe for multithreaded access. Thread
* safety is optional and may be enforced by classes that extend and implement
* this interface.
*