[hyddd的FindBugs分析记录][H C FS] More arguments are passed that are actually used in the format string
2009-02-13 17:07 hyddd 阅读(1533) 评论(0) 编辑 收藏 举报[H C FS] More arguments are passed that are actually used in the format string [VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED]
A format-string method with a variable number of arguments is called, but more arguments are passed than are actually used by the format string. This won't cause a runtime exception, but the code may be silently omitting information that was intended to be included in the formatted string.
这个错误很简单,是使用String.format的时候出了问题,format里面的参数没有被全部用上。
看下面一段代码:
String str1 = "123";
String str2 = "456";
String str3 = String.format("{0} {1}" , str1 ,str2);
System.out.println(str3);
}
输出的结果是:{0} {1}
这个Bug描述就是这种问题,str1和str2根本没有被用上!{0}{1}这种Format格式是.NET上面的用法,java里面应该是%s %s。
这个是一个代码逻辑问题,可能是你写代码时不小心导致的,它在这段代码里不会导致异常,但往往会很可能导致其他地方异常,那时候你可能会百思不得其解。
作者:hyddd
出处:http://www.cnblogs.com/hyddd/
本文版权归作者所有,欢迎转载,演绎或用于商业目的,但是必须说明本文出处(包含链接)。