[Training Video-3] [Groovy in Detail] Non-static and static variables in groovy

Source: Internet
Author: User

Log.info "Starting"//We use class to create  objects of a classplanet p1 = new Planet () Planet p2 = new Planet () Planet  P3 = new Planet ()//planet.name = "Pluto"  illegal planet.shape = "circle" p1.name = "earth"//p1.shape = "Circle" P2.name = "Jupiter"//p2.shape = "circle" P3.name = "mars"//p3.shape = "Circle" log.info p1.name+ "  +p1.shapelog.info p2.name+ "  " +p2.shapelog.info p3.name+ "  " +P3.SHAPEP1 = P2log.info "*************************************" Log.info P1.name+ "  " +p1.shapelog.info p2.name+ "  " +p2.shapelog.info p3.name+ "  " +p3.shapep1.name = "Pluto" Log.info "*************************************" Log.info p1.name+ "  +p1.shape    //plutolog.info p2.name+"  "+p2.shape    //plutolog.info p3.name+"  "+p3.shapeclass planet{//variables and functionsdef name    Non static variabledef static shape  //Static variable}

Operation Result:

Tue Oct 16:27:27 CST 2015:info:startingtue Oct 16:27:27 CST 2015:info:earth  circletue Oct 16:27:27 CST 2015:I Nfo:jupiter  circletue Oct 16:27:27 CST 2015:info:mars  circletue Oct 16:27:27 CST 2015:info:*************** Tue Oct 16:27:27 CST 2015:info:jupiter  circletue Oct 16:27:27 CST 2015:info:jupiter  Circletue Oct 16:27:27 CST 2015:info:mars  circletue Oct 16:27:27 CST 2015:info:******************************* Tue Oct 16:27:27 CST 2015:info:pluto  circletue Oct 16:27:27 CST 2015:info:pluto  circletue Oct 06 16:27 : CST 2015:info:mars  Circle

[Training Video-3] [Groovy in Detail] Non-static and static variables in groovy

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.