Extend a class without an constructor | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Extend a class without an constructor

Hey there, I'm new to java and I tried to make some nukkit plugins(mc bedrock edition server plugins). When I try to extend some classes, like the player class. My ide is showing an error and tell me to use the parent constructor. Is there an way to do it without using that parent constructor? So I fixed my self for now with an extra variable and don't extend from that class. Thx for help :)

16th Jun 2020, 10:02 AM
ImNotYourDev
ImNotYourDev - avatar
3 Answers
0
class A { A(int a) {System.out.println(a);} } class B extends A { B(int a) {super(a);} } public class Program { public static void main(String[] args) { B b = new B(100); } }
16th Jun 2020, 8:17 PM
zemiak
0
Yea I figured out my self. So that won't work for my situation/problem, but thx.
16th Jun 2020, 8:58 PM
ImNotYourDev
ImNotYourDev - avatar
0
it is better with question to publish the part of your code too
17th Jun 2020, 5:31 AM
zemiak