字符串
2020-03-15 本文已影响0人
龙剑灵
def str = "groovy"
println str.center(8)
println str.center(7, "+") //groovy+
println str.center(8, "+") //+groovy+
println str.padLeft(8, "+") //++groovy
println str.padRight(8, "+") //groovy++
def str2 = 'hello'
str = "groovy hello"
println str > str2 //false
println str[1]
println str[0..3] //groo
println str.minus(str2) //groovy
println str- str2 //groovy
println str.reverse() //olleh yvoorg
println str.capitalize() //Groovy hello