[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扫扫代码还是有点用处的~!

 

相关文章:

  • 2021-11-22
  • 2021-08-05
  • 2021-09-23
  • 2021-08-11
  • 2021-07-06
  • 2021-06-01
  • 2021-07-07
  • 2021-05-20
猜你喜欢
  • 2022-02-02
  • 2021-10-11
  • 2021-09-30
  • 2022-12-23
  • 2021-08-05
  • 2021-07-12
  • 2021-11-29
相关资源
相似解决方案