#Help With Constructor Error
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
when you inherit a class, you must call the parent constructor
i call the parent constructor inside the child constructor?
where ? that's not what I see
no im asking if thats what i should do
super(...)
and it should be the first line as well(not sure if they changed that?)
i did everything else right on the exam
but im getting a 0 because my code didnt compile
yes, currently it should be the first line
yes
you need to understand why you need to do that at the first place
let's say you don't call it
then those variables will be null
then the parent constructor doesn't construct it, so every field is null, and everything that should have been done isn't done, so now you have an object in an invalid state
so java ensures that you call it
always
in fact it ensures that you have at least one constructor too
and this even if you don't inherit any class
since if you don't inherit class
java will make you inherit Object
and will add a default constructor
the thing im confused about is what specifically do i put inside the super(), because my child constructor wasn't passed anything from the parent
which will contain a default super()
wdym
you need to pass a name and winglength
my parent constructor takes 2 arguments
ah ?
can I see the assignment ?
ah
then talk to your teacher when you will get your copy
👍