Why doesn't the java subclass inherit the parameterized constructor of the parent class?

the constructor with String of the JFrame class is obviously public, so why not inherit it to the subclass?

import javax.swing.*;

public class test extends JFrame
{    
    public test() {
        // TODO 
    }
    public static void main(String[] args) {
        JFrame frame=new test("123");
    }
    
}
Mar.12,2021

The constructor in the

parent class is inherited, but the subclass calls its own implicit constructor by default when it creates the object. If you want to use the parent constructor, override

with the constructor of the parent class
yourself.
import javax.swing.JFrame;

public class test extends JFrame
{    
    public test(String title) {
        // TODO 
        super(title);
    }
    public static void main(String[] args) {
        JFrame frame=new test("123");
    }
}
< hr > The

public-modified class means that this class can be opened to the public, other classes can inherit it, and the object can be instantiated externally.

if you don't add public, the default modifier is protected, for open only to the same package.


Why is your class name lowercase? did the compiler report no error

Menu