提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用b,B,h,H,%和n转换字符。
public class Main /*from 时代Java - nowjava.com*/ { public static void main(String[] args) { Object test = null; System.out.printf("%b\n", false); System.out.printf("%b\n", true); System.out.printf("%b\n", "Test"); System.out.printf("%B\n", test); System.out.printf("Hashcode of \"hello\" is %h\n", "hello"); System.out.printf("Hashcode of \"Hello\" is %h\n", "Hello"); System.out.printf("Hashcode of null is %H\n", test); System.out.printf(