码迷,mamicode.com
首页 > 其他好文 > 详细

[Groovy]String Functions

时间:2015-06-16 16:37:45      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

def x="I like to read books before bed"
def temp = x.split(" ")
log.info "Size of array is : "+temp.length
log.info temp[0]
log.info temp[1]
log.info x.substring(2,8)
log.info x.indexOf("t")
log.info x.indexOf("book")
log.info x.indexOf("e",6)
log.info x.charAt(5)

 Result:

Tue Jun 16 14:40:49 CST 2015:INFO:Size of array is : 7
Tue Jun 16 14:40:49 CST 2015:INFO:I
Tue Jun 16 14:40:49 CST 2015:INFO:like
Tue Jun 16 14:40:49 CST 2015:INFO:like t
Tue Jun 16 14:40:49 CST 2015:INFO:7
Tue Jun 16 14:40:49 CST 2015:INFO:15
Tue Jun 16 14:40:49 CST 2015:INFO:11
Tue Jun 16 14:40:49 CST 2015:INFO:e

def a = "100"
def b = "200"
def c = Integer.parseInt(a) + Integer.parseInt(b)
log.info "sum = " + c

def d = 100
def n = String.valueOf(d)
log.info "d =  " + d

 Result:

Tue Jun 16 14:45:55 CST 2015:INFO:sum = 300
Tue Jun 16 14:45:55 CST 2015:INFO:d =  100


[Groovy]String Functions

标签:

原文地址:http://www.cnblogs.com/MasterMonkInTemple/p/4580763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!