URL url = MyImageIcon.class.getResource("1.jpg"); Icon icon = new ImageIcon(url);
这里的代码属于向上转型的吗?
new了一个ImageIcon 并初始化了参数 就是调用了ImageIcon的带参的构造方法