2016/1/17 Rectangular Area 1, construction method initialize length and width, 2, define member method to find rectangular area

Source: Internet
Author: User

1  Public classSquare {2 intChang;3 intKuan;4 intMianji;5 String colour;6 //constructor Method One parameter7Square (intCintk) {8chang=C;9kuan=K;Ten } One Square (String se) { AColour=se; - } - //construction Method Two no parameter default is None the Square () { -      - } -  + //No return value no parameter - /*void Juxing () { + Mianji=chang*kuan; A }*/ at  - //two no return values have parameters - /*void juxing (int chang,int Kuan) { - Mianji=chang*kuan; -      - }*/ in  - //three have return values without parameters to intjuxing () { +mianji=chang*Kuan; -     returnMianji; the } * //four have return values with parameters $ /*int juxing (int chang,int Kuan) {Panax Notoginseng Mianji=chang*kuan; - return Mianji; the      + }*/ A  the  Public Static voidMain (string[] args) { +      -      $Square shu=NewSquare (4,3); $      -System.out.println ("rectangular area =" +shu.juxing ()); -      the      -     WuyiSquare ss=NewSquare ("Green"); the System.out.println (); - System.out.println (ss.colour); Wu }  -}

2016/1/17 Rectangular Area 1, construction method initialize length and width, 2, define member method to find rectangular 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.