[Groovy] String Functions

Source: Internet
Author: User

def x= "I like to read books before Bed" Def temp = X.split ("") Log.info "Size of an array is:" +temp.lengthlog.info Temp[0]lo G.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 June 14:40:49 CST 2015:info:size of array is:7
Tue June 14:40:49 CST 2015:info:i
Tue June 14:40:49 CST 2015:info:like
Tue June 14:40:49 CST 2015:info:like t
Tue June 14:40:49 CST 2015:info:7
Tue June 14:40:49 CST 2015:info:15
Tue June 14:40:49 CST 2015:info:11
Tue June 14:40:49 CST 2015:info:e

def a = "+" Def B = "$" def C = Integer.parseint (a) + Integer.parseint (b) log.info "sum =" + cdef D = 100def n = String. ValueOf (d)
Log.info "D =" + D

Result:

Tue June 14:45:55 CST 2015:info:sum = 300
Tue June 14:45:55 CST 2015:info:d = 100


[Groovy] String Functions

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.