ITeye博客

findBugs记录

fourfire · 2010-04-07 08:22 · Java · 非技术 · Markdown

1 在0-n之间取随机数,使用 java.util.Random r=new java.util.Random(); r.nextInt(n); 而不使用 (int)(r.nextDouble() * n) If r is a java.util.Random, you can generate a random number from 0 to n-1 using r.nextInt(n), rather than using (int)(r.nextDouble() * n). 2 在实例中修改静态类的属性 public void process(File fs) { UtilTools.rootPath = "d:/tmp/"; ... This instance method writes to a static field. This is tricky to get correct if multiple instances are being manipulated, and generally bad practice

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。