惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - Franky
V
V2EX
爱范儿
爱范儿
J
Java Code Geeks
小众软件
小众软件
Last Week in AI
Last Week in AI
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
The Register - Security
The Register - Security
GbyAI
GbyAI
Vercel News
Vercel News
Y
Y Combinator Blog
腾讯CDC
F
Fortinet All Blogs
I
InfoQ
N
Netflix TechBlog - Medium
B
Blog RSS Feed
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
Scott Helme
Scott Helme
T
Tor Project blog
U
Unit 42
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
D
Darknet – Hacking Tools, Hacker News & Cyber Security
aimingoo的专栏
aimingoo的专栏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
Security Archives - TechRepublic
Security Archives - TechRepublic

qubeijun的博客

言语理解与表达 父亲往事-我儿子叫冬冬 公务员行测答题顺序及用时及答题技巧 判断推理 数量关系 冬甜夫妇5-10-5-21日本蜜月行程安排回归总结篇(无图片) 冬甜夫妇5.10-5.21日本蜜月行程安排计划篇 5.1 小贝壳疫苗计划 100DAYS 父亲往事-猴牤大爷的“帽子” 父亲往事-姨妈家的葡萄架 父亲往事-十五的月饼 父亲往事-姑妈的压岁钱 父亲往事-母亲的缝纫机父亲的锯 父亲往事-家属来队 父亲往事-新兵连的生活 父亲往事-村北的槐树林 父亲往事-小贝壳 公务员面试 系统架构设计师 图形推理 数学运算 父亲往事-惊蛰 资料分析 父亲往事-偷吃西红柿有绝窍 父亲往事-毯子衣服 父亲往事-水壶煮鸡蛋 父亲往事-煎饼蘸香油 系统架构设计师论文 软件设计师 父亲往事-大哥 资料分析-旧 基于grafana的监控部署 mysql数据库定时备份&运行日志定时清理 各种问题解决答案汇总 Alibaba Cloud Toolkit的使用说明 Dojo简单入门 Angular简单入门 vue基础知识点总结 java正则表达式收集 java处理时间和日期api java常用的io,输入输出 java常见集合汇总 java调试代码不再用system.out.println(),用日志来调试程序 java常用工具类总结 python之pymysql增删改查mysql数据库 词性标注集 python获取当前文件夹下的所有的文件名 mysql数据库操作总结 (翻译)Understanding LSTM Networks (翻译)Understanding Convolutional Neural Networks for NLP (翻译)传统和深度学习模型在文本分类中的应用综述与基准 小木虫论坛-学术科研互动平台爬虫 solr命令(持续更新) python json读写操作 python pip安装包镜像 python数字进度条 抓取维基百科分类索引下某一分类下的子分类及其分类下的页面(仅限词条) python3循环读取excel文件并写入json python3 requests动态网页post提交数据 python+selenium搜狗微信主页抓取 2017年5月25日 2017年5月18日 2017年5月17日 2017年5月15日 2017年5月16日 2017年5月14日 2017年5月13日 2017年5月12日 2017年5月11日 2017年5月10日 2017年5月9日 2017年5月8日 2017年5月7日 2017年5月6日 2017年5月5日 2017年5月4日 2017年5月3日 2017年5月2日 2017年5月1日 儿子的信-2013年7月9日 儿子的信-2013年7月8日 儿子的信-2011年11月26日 儿子的信-2010年8月16日 儿子的信-2010年1月2日
java常用字符串操作总结
qubeijun · 2020-02-25 · via qubeijun的博客

发表于|更新于|java

|总字数:620|阅读时长:3分钟|浏览量:|

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package _22javacoreclass;

public class Main{
public static void main(String[] args){
String s1 = "hello";
String s2 = "HELLO";
String s3 = new String(new char[]{'h','e','l','l','o'});
String s4 = s1.toUpperCase();


// 1.字符串比较
System.out.println(s1.equals(s4)); // false
// 2.忽略大小写比较
System.out.println(s1.equalsIgnoreCase(s2)); // true
// 3.是否包含子串
System.out.println("Hello".contains("ll")); // true
// 4.返回第一个匹配字符的索引
System.out.println("Hello".indexOf("l")); // 2
// 5.返回最后一个匹配字符的索引
System.out.println("Hello".lastIndexOf("l")); // 3
// 6.是否以指定字符串前缀开始
System.out.println("Hello".startsWith("He")); // true
// 7.是否以指定字符串结尾
System.out.println("Hello".endsWith("lo")); // true
// 8.提取2到结尾子串
System.out.println("Hello".substring(2)); //"llo"
// 9.提取2到3子串
System.out.println("Hello".substring(2, 4)); //"ll"
// 10.去除收尾空白字符
System.out.println(" \tHello\r\n ".trim()); // "Hello"
// 11.去空格 java11以后特性
// System.out.println("\u3000Hello\u3000".strip()); // "Hello"
// 12.去前缀空格 java11以后特性
// System.out.println(" Hello ".stripLeading()); // "Hello "
// 13.去结尾空格 java11以后特性
// System.out.println(" Hello ".stripTrailing()); // " Hello"
// 14.判断字符串是否为空
System.out.println("".isEmpty()); //true
System.out.println(" ".isEmpty()); //false
// 15.判断字符串是否包含空白字符串 java11以后特性
// System.out.println(" \n".isBlank()); //true
// System.out.println(" Hello ".isBlank()); //false
// 16.替换子串
System.out.println("hello".replace('l','w')); // hewwo
// 17.表达式替换
System.out.println("A,,B;C ,D".replaceAll("[\\,\\;\\s]+", ",")); // A,B,C,D
// 18.分割字符串
System.out.println("A,B,C,D".split("\\,")); // {"A","B","C","D"}
// 19.拼接字符串
String[] arr = {"A", "B", "C"};
System.out.println(String.join("***",arr)); //A***B***C
// 20.类型转换为字符串
System.out.println(String.valueOf(123)); // "123"
System.out.println(String.valueOf(45.67)); // "45.67"
System.out.println(String.valueOf(true)); // "true"
System.out.println(String.valueOf(new Object())); //类似java.lang.Object@4554617c
// 21.字符串转换为int
System.out.println(Integer.parseInt("123")); //123
System.out.println(Integer.parseInt("ff",16)); //按十六进制转换, 255
// 22.字符串转换为boolean
System.out.println(Boolean.parseBoolean("true")); //true
System.out.println(Boolean.parseBoolean("FASLE")); //false
// 23.转换为char[]
char[] cs = "Hello".toCharArray();
System.out.println(cs); //String转char[], Hello
System.out.println(new String(cs)); //char[]转String, Hello
}
}

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 qubeijun的博客

赞助

  • 微信

    微信

  • 支付宝

    支付宝