复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31public class Main { public static void main(String[] args) { String[] strs={ "#abc", "abcd", "#abcde", "#abcdef", "abcdefg", "abcdefgh#", "abcdefghi#", }; System.out.println("开头有#:"); for(String str:strs) { if(str.startsWith("#")) { System.out.println(str); } } System.out.println("结尾有#:"); for(String str:strs) { if(str.endsWith("#")) { System.out.println(str); } } } }
运行结果:
最后
以上就是英勇大米最近收集整理的关于java String 中 startsWith() 对字符串开头进行过滤 endsWith()对字符串结尾进行过滤的全部内容,更多相关java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复