我正在从一位同事(另一位学生)那里进行Java代码的"静态"代码演练
对我来说,这没有意义; 从上到下阅读这些"组件"对象在声明之前进行实例化(稍后在构造函数中使用).但是,代码很乐意编译并运行.这是不好的做法吗?
Public Class theObject {
private static final long aVariable = 123123123123123;
public theObject(...){
componentOne = new Component(...);
componentTwo = new Component(...);
...
...
componentOne.doSomething(...);
}
private Component componentOne;
private Component componentTwo;
}
Run Code Online (Sandbox Code Playgroud)