JAVA 常用的是字符串处理函数2

字母的大小写转换

str.toLowerCae();-------------->hello world
str.toUpperCase();------------->HELLO WORLD


字符串的分割(字符串转数组)
split 方法的结果是一个字符串数组,
str.split(String a;int n)//a:从a处分割        n:分割的份数
Arrays.toString(str.split("o"))------------->[Hell,  W, rld]
Arrays.toString(str.split("o",2))----------->[Hell,  World]

 


判断字符串的开始和结束
str.startsWith("H")---------------->true    判断str是否是以字符串"H"开头
str.endWith("d")------------------->true    判断str是否是以字符串"d"结尾
原文链接:https://blog.csdn.net/m0_46319611/article/details/121308602

posted @ 2022-10-19 14:40  一只忙碌的蜗牛  阅读(15)  评论(0编辑  收藏  举报