Why does Java bind variables at compile time?

前端 未结 4 593
心在旅途
心在旅途 2020-12-04 14:15

Consider the following example code

class MyClass {
    public String var = \"base\";

    public void printVar() {
        System.out.println(var);
    }
}
         


        
4条回答
  •  失恋的感觉
    2020-12-04 14:40

    The polymorphic behaviour of the java language works with methods and not member variables: they designed the language to bind member variables at compile time.

提交回复
热议问题