There are no parent constructors that match the 'super()' that you are calling. Example:
classEx1{publicEx1(int temp){}}classEx2extendsEx1{publicEx2(){//super("5"); !~ERROR, no super constructor that takes a String//super(); !~ERROR, no super constructor with no argumentssuper(5);// this is good because it matches a parent constructor}}
↑ Briefly two classes where the second class extends the first one. They both have constructors. In the child class you MUST call a valid constructor (literally any accessible constructor) from the parent class on the first line of code inside the child's constructor.
The only time you don't need to use super in a constructor is if:
1) The parent class has a constructor with no parameter:
classEx1{publicEx1(){}}classEx2extendsEx1{publicEx2(){// doesn't need super because parent has a constructor with no parameters}}
2) The constructor calls another constructor with 'this' that calls a valid parents constructor:
classEx1{publicEx1(int temp){}}classEx2extendsEx1{publicEx2(){this(5);// calls another constructor that calls a parent's constructor}publicEx2(int temp){super(5);}}
Last little rule. Anytime you use 'super' or 'this' to call a constructor it MUST be the very first line of code in the constructor. Any lines of code prior to the super or this constructor call will produce an error:
constructor {int x =5;super(x);// !~ this line of code will give you an error}
constructor {int x =5;this(x);// !~ this line of code will give you an error}
I understand that the compiler doesn’t see a string in the BufferedWriter, so:
String destinationFileName = name of the destination file;
I wrote:
Super (this) // Error
super (destinationFileName) // error
super (“target filename”) // error
IDEA sees no problem everything works as it should. Only CodeGym has a problem.
You have created a custom class, "FileOutputStreamWrite", which extends "OutputStreamWriter". In the OutputStreamWriter class there are 4 constructors:
1) OutputStreamWriter(OutputStream out)
2) OutputStreamWriter(OutputStream out, Charset cs)
3) OutputStreamWriter(OutputStream out, CharsetEncoder enc)
4) OutputStreamWriter(OutputStream out, String charsetName)
This means that your custom class needs to call one of those constructors to work properly. This is what is causing your error.
We need to see your whole code if you want any more help. The output that you shared only shows an improper call to the parent constructor with no arguments.
I see you posted your full code on another question. See my response there.
0
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.