如果我有这个示例代码:
public class Test{
static String myVariable = "hi";
public Test(){
System.out.println(myVariable);
System.out.println(Test.myVariable);
}
public static void main(String[] args) throws SQLException{
new Test();
}
}
Run Code Online (Sandbox Code Playgroud)
现在两者都会打印"hi",但我想知道它们的区别是什么,何时我应该使用另一个,或者我应该总是只使用其中一个,因为它是常态.
对于这个非常基本的例子我很抱歉,但是当我让系统工作时,我并没有真正理解两者之间的区别
java ×1