Groovy(二)

2022/1/27 23:07:05

本文主要是介绍Groovy(二),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Groovy(二)基础

String

创建字符串字面常量

通过Groovy将''定义的类型认定为String

println "-----------------String---------------"
def tStr = "hello word";
println 'hello word'.class
char tChar = 'c'
println tChar.class

在这里插入图片描述

多行字符串

减少连接符和转义字符的使用

sb = new StringBuffer()
sb.append('''
^    ^
 ____
''')
println sb

在这里插入图片描述



这篇关于Groovy(二)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程