6. def name='World' def list = ["Hello", " ", "World"]
println "Hello $name!" list.each{
print it
}
class Greet {
def name
Greet(who) { name = who[0].toUpperCase() +who[1..-1] }
def salute() { println "Hello $name!" }
}
def g = new Greet('world')
// create object
g.salute()
7.
8. import java.util.Date; } return this.black;
public Integer getColorId() { }
public class Color { return this.colorId; public void setBlack(String black) {
private Integer colorId; } this.black = black;
private String colorName; public void setColorId(Integer colorId) { }
private String cyan; this.colorId = colorId; public String getRgb() {
private String magenta; } return this.rgb;
private String yellow; public String getColorName() { }
private String black; return this.colorName; public void setRgb(String rgb) {
private String rgb; } this.rgb = rgb;
private String sysIpaddress; public void setColorName(String }
private Date sysLastmodified; colorName) { public String getSysIpaddress() {
private Integer sysUid; this.colorName = colorName; return this.sysIpaddress;
public Color(Integer colorId, String } }
colorName, String cyan, public String getCyan() { public void setSysIpaddress(String
String magenta, String yellow, String return this.cyan; sysIpaddress) {
black, String rgb, } this.sysIpaddress = sysIpaddress;
String sysIpaddress, Date public void setCyan(String cyan) { }
sysLastmodified, Integer sysUid) { this.cyan = cyan; public Date getSysLastmodified() {
this.colorId = colorId; } return this.sysLastmodified;
this.colorName = colorName; public String getMagenta() { }
this.cyan = cyan; return this.magenta; public void setSysLastmodified(Date
this.magenta = magenta; } sysLastmodified) {
this.yellow = yellow; public void setMagenta(String magenta) { this.sysLastmodified = sysLastmodified;
this.black = black; this.magenta = magenta; }
this.rgb = rgb; } public Integer getSysUid() {
this.sysIpaddress = sysIpaddress; public String getYellow() { return this.sysUid;
this.sysLastmodified = sysLastmodified; return this.yellow; }
this.sysUid = sysUid; } public void setSysUid(Integer sysUid) {
} public void setYellow(String yellow) { this.sysUid = sysUid;
public Color() {} this.yellow = yellow; }
public Color(Integer colorId) { } }
this.colorId = colorId; public String getBlack() {
9. class Color {
Integer colorId
String colorName
String cyan,magenta,yellow,black,rgb
String sysIpaddress
Date sysLastmodified
Integer sysUid
}
class Color {
Integer colorId, sysUid
String colorName,cyan,magenta,yellow,black,rgb,sysIpaddress
Date sysLastmodified
}
10.
11. String name = 'World'
↓
def name='World'
class Dog {
def say(){ // ←
“Garuuuuu”
}
}