[H C FS] Format string references missing argument [VA_FORMAT_STRING_MISSING_ARGUMENT]
Not enough arguments are passed to satisfy a placeholder in the format string. A runtime exception will occur when this statement is executed.
看实例代码:
public static void main(String args[]) throws Exception{
String sqlrightDate = "select state from right where user_id = '%s' and soft_code ='%s' and right_name = '%s' ";
String str = String.format(sqlrightDate,"1" ,"2");
System.out.println(str);
}
对,你没有眼花,format里面只传了两个参数,但sqlrightData需要的是三个参数!这可能值是你的一个笔误,相信没人会故意写这样的代码,但编译器检查不出这种问题,这导致运行时这里会抛异常,所以用FindBugs扫扫代码还是有点用处的~!
String sqlrightDate = "select state from right where user_id = '%s' and soft_code ='%s' and right_name = '%s' ";
String str = String.format(sqlrightDate,"1" ,"2");
System.out.println(str);
}