只是澄清这段代码

时间:2015-05-21 16:33:37

标签: java

我只想简单澄清这两行代码。这两者之间的区别是什么?

SuperClass c = new JustTesting(1, 'b');
JustTesting b = new JustTesting(2, 'c'); 

顺便说一下,如果您想查看完整代码,请点击此处:

import static java.lang.System.out;

public class JustTesting extends SuperClass{

public JustTesting(int firstVar, char secondVar) {
    super(firstVar, secondVar);
}

public static void main(String[] args) {
    SuperClass c = new JustTesting(1, 'b');
    JustTesting b = new JustTesting(2, 'c'); 
    out.println(c.firstVar);
    out.println(b.firstVar);
}
}

0 个答案:

没有答案