import scala.collection.mutable.ListBuffer
val test_hash = new collection.mutable.HashSet[String]()
test_hash.add("123")
test_hash.add("126")
test_hash.add("125")
test_hash.add("124")
val list_test = new ListBuffer[String]()
if(test_hash.contains("123")){
list_test.append("TTT")
}else{
println("FFF")
}
println(list_test)
// 去除字符串前后空格
val str = " hello "
println(str.trim) //hello
scala中去除字符串前后空格API---trim,自定义hashset用来存储元素作为查找是否存在
Scala字符串处理:trim与自定义HashSet用法
最新推荐文章于 2025-02-07 08:48:56 发布
本文介绍了Scala中如何使用trim方法去除字符串前后空格,并讲解了利用自定义HashSet存储元素以进行高效查找的操作。通过实例展示了这两个功能在实际编程中的应用。
3758

被折叠的 条评论
为什么被折叠?



