// Jakarta Commons Loggingprivate static final Log log = LogFactory.getLog(MyClass.class);The above code also shows another good practice, which is to pass the Class object to the getLog() method, instead of a string. Why the java.util.logging.Logger…
用Resharper的同学都知道,如果你写了一个私有函数,这个函数没有访问类里面的其他参数和方法,那么它建议你标记这个方法为私有静态方法,提示是这样的: 值得这样做吗?看看微软的建议: After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting non-virtual call sites will prevent a check at…
很多时候一个新手在写代码的时候,往往你的IDE就会告诉你一个警告 然后你点击处理这个警告之后,它就会默认给你的类生成一个 private static final long serialVersionUID = 1L; 然后强迫症的孩子就一直不明白为什么会需要这个东西,这个东西到底是干嘛用得呢? 然后渐渐的你会发现,这个东西和你写的代码毫无关系,没什么卵用,于是渐渐的你就把他扔在一边了. 这次我就需要来解决这个问题,困扰你的private static final long serialVers…
当前需求: 利用反射获取某一属性值运行结果:java.lang.IllegalAccessException: Class com.example.demo.test.Reflect can not access a member of class com.example.demo.test.EvalNum with modifiers "private static"... 反射用到的Bean类: package com.example.demo.test; import java.…