This document introduces the Groovy programming language and summarizes some of its key features. It discusses how Groovy combines the power of Java with the lightweight syntax of dynamic languages like Ruby. Some highlighted features include: dynamic typing, direct property access, powerful string interpolation, simple collection types, operator overloading, switch statements, closures, and more. The document encourages readers to explore Groovy further on its website.
9. Copyright ? 2001-2006 Infor Global Solutions ±ðÔÚºõÀàÐÍ Java: String name = ¡°abc¡±; Groovy: String name = ¡°abc¡± def name name = ¡°abc¡±
10. Copyright ? 2001-2006 Infor Global Solutions ¡° Ö±½Ó¡±·ÃÎÊÊôÐÔ class Person { private String name; public Person(String name) {this.name = name;} public String getName() {return name;} } Person person = new person(¡°ocean¡±) return person.getName(); class Person { String name; } Person person = new Person(name:¡±ocean¡±) return person .name
11. Copyright ? 2001-2006 Infor Global Solutions Á˲»ÆðµÄ×Ö·û´® firstName = ¡°ocean¡± lastName = ¡°dong¡± message = ¡°My name is $ firstName $ lastName¡± person = new Person() person.setName(¡°ocean¡±) message = ¡°My name is ${ person.name } ¡± Message = ¡° ¡°¡° Hi, My name is ${person.name} ¡±¡±¡± def pattern = / hello.* /
15. Copyright ? 2001-2006 Infor Global Solutions ËÄͨ°Ë´ïµÄ Switch switch(10) { case 0: case 0..9: case [8,9,11]: case Float: case {it % 3 == 0}: case ~/../: default: }