当前位置: 技术问答>java相关
关于超类构造器的问题
来源: 互联网 发布时间:2015-06-12
本文导语: 有如下一段java程序: import java.awt.image.ImageConsumer; import java.awt.image.MemoryImageSource; import java.awt.image.ColorModel; import java.util.Hashtable; class anfy extends MemoryImageSource { // Fields private ImageConsumer lastConsumer; // Con...
有如下一段java程序:
import java.awt.image.ImageConsumer;
import java.awt.image.MemoryImageSource;
import java.awt.image.ColorModel;
import java.util.Hashtable;
class anfy extends MemoryImageSource {
// Fields
private ImageConsumer lastConsumer;
// Constructors
public anfy(int p0, int p1, int[] p2, int p3, int p4) { }
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5){ }
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5, Hashtable p6) {}
public anfy(int p0, int p1, ColorModel p2, byte[] p3, int p4, int p5) { }
// Methods
public ImageConsumer getConsumer() { }
public synchronized void addConsumer(ImageConsumer p0) { }
}
编绎后出现这个问题:
"anfy.java": Error #: 300 : constructor MemoryImageSource() not found in class java.awt.image.MemoryImageSource at line 17, column 10
找不到java.awt.image.MemoryImageSource.MemoryImageSource()方法的构造器??
谁来帮我解决这个问题?
import java.awt.image.ImageConsumer;
import java.awt.image.MemoryImageSource;
import java.awt.image.ColorModel;
import java.util.Hashtable;
class anfy extends MemoryImageSource {
// Fields
private ImageConsumer lastConsumer;
// Constructors
public anfy(int p0, int p1, int[] p2, int p3, int p4) { }
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5){ }
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5, Hashtable p6) {}
public anfy(int p0, int p1, ColorModel p2, byte[] p3, int p4, int p5) { }
// Methods
public ImageConsumer getConsumer() { }
public synchronized void addConsumer(ImageConsumer p0) { }
}
编绎后出现这个问题:
"anfy.java": Error #: 300 : constructor MemoryImageSource() not found in class java.awt.image.MemoryImageSource at line 17, column 10
找不到java.awt.image.MemoryImageSource.MemoryImageSource()方法的构造器??
谁来帮我解决这个问题?
|
在所有anfy的构造函数中加上 super(...);
public anfy(int p0, int p1, int[] p2, int p3, int p4) { super(p0,p1,p2,p3,p4);}
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5){ super(p0,p1,p2,p3,p4,p5);}
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5, Hashtable p6) { super(p0,p1,p2,p3,p4,p5,p6);}
public anfy(int p0, int p1, ColorModel p2, byte[] p3, int p4, int p5) { super(p0,p1,p2,p3,p4,p5);}
public anfy(int p0, int p1, int[] p2, int p3, int p4) { super(p0,p1,p2,p3,p4);}
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5){ super(p0,p1,p2,p3,p4,p5);}
public anfy(int p0, int p1, ColorModel p2, int[] p3, int p4, int p5, Hashtable p6) { super(p0,p1,p2,p3,p4,p5,p6);}
public anfy(int p0, int p1, ColorModel p2, byte[] p3, int p4, int p5) { super(p0,p1,p2,p3,p4,p5);}