最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
java中简单的截取分割字符串实例
时间:2022-06-29 01:35:15 编辑:袖梨 来源:一聚教程网
目前整理出来三种形式:
可根据实际需要选择使用
| 代码如下 | 复制代码 |
String userNameUrl; intbeginIndex =0; intendIndex =0; userNameUrl ="454512@hongri@4944115455d9591b274648a06303d910de";
/** * 方法一: */ beginIndex = userNameUrl.indexOf("@")+1; endIndex = userNameUrl.lastIndexOf("@"); System.out.println(userNameUrl.substring(beginIndex,endIndex)); /** * 方法二: */ System.out.println(userNameUrl.split("@")[1].toString()); /** * 方法三: */ System.out.println(userNameUrl.substring(7,13)); | |
运行结果:
相关文章
- 嘎嘎射击战斗鸡怎么样 嘎嘎射击战斗鸡玩法特色与实战体验分析 03-23
- 鸣潮偏谐是什么机制 鸣潮偏谐机制解析 03-23
- 逆战未来兽神(Boss流)插件推荐 03-23
- 永辉生活app几点补货 03-23
- 小米平板6大概什么价位 03-23
- 小黄蜂手机怎么样 03-23
