[Training Video-4] [Groovy] Constructors in groovy, this keyword

Source: Internet
Author: User

Bank.log = Logbank B1 = new Bank () B1.name = "BOA" b1.minbalance = 100b1.city= "London" Bank b2 = new Bank () B2.name = "HSBC" B2  . minbalance = 100b2.city= "LA" Bank B3 = new Bank ("A", "X") log.info b3.namebank b4 = new Bank ("B", "Max", "X1") Bank B5 = new Bank ("C", 1300, "X2") log.info b5.minbalanceclass bank{def static logdef namedef minbalancedef Citypublic Bank () {      // No return type, same name with class Namelog.info "inside Constructor"}//public Bank (bankname,bankminbal,bankcity) {// Name = Bankname//minbalance = Bankminbal//city = Bankcity//}public Bank (name,minbalance,city) {this.name = namethis.minbalance = Minbalancethis.city = City}}

Run Result:

Tue Oct 19:51:29 CST 2015:info:inside constructortue Oct 19:51:29 CST 2015:info:inside constructortue Oct 06 19:51:2 9 CST 2015:info:atue Oct 19:51:29 CST 2015:info:1300

[Training Video-4] [Groovy] Constructors in groovy, this keyword

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.