boolean类型格式化问题
public class Main {
public static void main(String[] args) {
// write your code here
System.out.println(String.format("%s" , true));
System.out.println(String.format("%b" , true));
System.out.println(String.format("%s" , new Boolean(true)));
System.out.println(String.format("%b" , new Boolean(true)));
System.out.println(String.format("%s" , null));
System.out.println(String.format("%b" , null));
}
}
/**
* true
* true
* true
* true
* null
* false
*/
// 所以对于boolean格式化的时候要用%b,而不能用%s。