If a class defines one or more constructor methods, Java does not provide the default constructor.

Source: Internet
Author: User
Class Trapezoid
{
Float upper bottom, lower bottom, high;
 
Trapezoid (float X, float y, float H)
{
Bottom = X;
Bottom = y;
Height = h;
}
Float calculation area ()
{
Float area;
Area = (upper bottom + lower bottom) * High/2.0f;
Return area;
}
Void height (float height)
{
Height = height;
}
Float get high ()
{
High return;
}
}
Class Area
{
Public static void main (string ARGs [])
{
Trapezoid ladertwo = new trapezoid (2.0f, 3.0f, 10.0f );
// Lader = new trapezoid ();
// Ladertwo = new trapezoid (2.0f, 3.0f, 10.0f );
// System. Out. println ("lader" + lader. Get high ());
System. Out. println ("ladettwo" + ladertwo. Get high ());
// System. Out. println ("lader" + lader. Calculated area ());
System. Out. println ("ladertwo" + ladertwo. Calculated area ());
// Lader. Modify height (10 );
Float H = 2.0f;
Ladertwo. Modify height (H * 2 );
// System. Out. println ("lader's current height" + lader + "ladertwo's current height" + ladertwo );
// System. Out. println ("Current lader area" + lader. Calculated area () + "Current lader. Two area" + ladertwo. Calculated area ());
}
}

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.