[J2SE 5.0 topic] [2.8] C style formatted output

xiaoxiao2021-03-06  45

Have you ever feel that the Printf in C is very pleasant, but does not have a similar convenience in Java? Now, our Java has also begun to support the Printf () method, which is based on the variable length parameters.

For example, we can write now:

System.out.printf ("% s Has a value of% d.% N", someString, A);

How, look good? It should be noted that Java adds the% N flag to the support of the multi-platform, which is supplemented with / N.

More detailed content, reference

Java.util.Formatter's API documentation.

转载请注明原文地址:https://www.9cbs.com/read-75520.html

New Post(0)