What is it about?
What is it about?
Dyskutowane
Komentarze (4)
- Popularne
- Najnowsze
- Najstarsze
Musisz się zalogować, aby dodać komentarz
Guadalupe Gagnon
8 sierpnia 2022, 19:25
There are no parent constructors that match the 'super()' that you are calling. Example:
↑ 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:
2) The constructor calls another constructor with 'this' that calls a valid parents constructor:
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:
0
Mateusz
9 sierpnia 2022, 17:12
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.
0
Guadalupe Gagnon
9 sierpnia 2022, 17:21
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.
0
Guadalupe Gagnon
9 sierpnia 2022, 17:49
I see you posted your full code on another question. See my response there.
0