Let's look at this program. Why is such an "inheritance" error?

Source: Internet
Author: User

Abstract class glyph {
Abstract void draw ();
Glyph (){
System. Out. println ("glyph () before draw ()");
Draw ();
System. Out. println ("glyph () after draw ()");
}
}

Class roundglyph01 extends glyph {
Int radius = 0;
String S;
Roundglyph01 (int r, string s ){
Radius = R;
This. S = s;
System. Out. println ("roundglyph01.roundglyph (), radius =" + radius + "" + S );
}
Void draw (){
System. Out. println ("roundglyph01.draw (), radius =" + radius + "" + S );
}
}

Class roundglyph02 extends glyph {
Int radius = 0;
String S;
Roundglyph02 (int r, string s ){
Radius = R;
This. S = s;
System. Out. println ("roundglyph02.roundglyph (), radius =" + radius + "" + S );
}
Void draw (){
System. Out. println ("roundglyph02.draw (), radius =" + radius + "" + S );
}
}

Class roundglyph03 extends roundglyph01 {
Int radius = 0;
String S;
Roundglyph03 (int r, string s ){
Radius = R;
This. S = s;
System. Out. println ("roundglyph03.roundglyph (), radius =" + radius + "" + S );
}
Void draw (){
System. Out. println ("roundglyph03.draw (), radius =" + radius + "" + S );
}
}

public class polyconstructors {
Public static void main (string [] ARGs) {
system. out. println ("creating object rounddlyph01... ");
New roundglyph01 (5," string ");
system. out. println ("************************************* *********");
system. out. println ("creating object rounddlyph02... ");
New roundglyph02 (5," string ");
system. out. println ("************************************* *********");
system. out. println ("creating object rounddlyph03... ");
New roundglyph03 (5," string ");
system. out. println ("************************************* *********");
}< BR >}< br>

Compilation result:
Polyconstructors. Java: 40: cannot resolve symbol
Symbol: constructor roundglyph01 ()
Location: Class roundglyph01
Roundglyph03 (int r, string s ){
^
1 error

After testing, if I inherited roundglyph03 from glyph instead of roundglyph01, everything would work normally. Why did the above error occur when I inherited roundglyph01?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.