我想知道将私有方法声明为最终是否有意义,我认为这没有意义.但我想象有一个独特的情况,并编写代码来弄清楚:
public class Boom {
private void touchMe() {
System.out.println("super::I am not overridable!");
}
private class Inner extends Boom {
private void touchMe() {
super.touchMe();
System.out.println("sub::You suck! I overrided you!");
}
}
public static void main(String... args) {
Boom boom = new Boom();
Boom.Inner inner = boom.new Inner();
inner.touchMe();
}
}
Run Code Online (Sandbox Code Playgroud)
它编译和工作."我应该让touchMe()最终成功"我想到并做到了:
public class Boom {
private final void touchMe() {
System.out.println("super::I am not overridable!");
}
private class Inner extends Boom {
private void touchMe() {
super.touchMe();
System.out.println("sub::You suck! I …Run Code Online (Sandbox Code Playgroud) 例如,我有一个声明
"SELECT * FROM Reports WHERE StartDate >= ? WHERE EndDate <= ? AND Performer = ?"
但有时网页上的某些输入字段没有填写,所以我不必考虑这个条件.即我没有填充开始日期,所以必须声明
"SELECT * FROM Reports WHERE EndDate <= ? AND Performer = ?"
有3种不同的条件.那么,我是否必须编写8种不同的语句和DAO方法来完成任务?真?也许有其他解决方案?
编辑:我使用MySQL /
在单例类中有一个org.apache.log4j.Logger字段是否可以?可能是任何并发问题,因为在多个线程之间共享它?