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

推荐订阅源

T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
H
Hacker News: Front Page
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
I
InfoQ
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
月光博客
月光博客
爱范儿
爱范儿
Jina AI
Jina AI
WordPress大学
WordPress大学
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
博客园 - 司徒正美
Scott Helme
Scott Helme
AI
AI
L
LangChain Blog
A
Arctic Wolf
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - 叶小钗
Last Week in AI
Last Week in AI
S
Secure Thoughts

博客园 - 空气

没有不可能的事情 迅景如梭,旧游似梦,烟水程何限 [转]一些web开发中常用的、做成cs文件的js代码 数类 MBTI职业性格测试 Which Programming Lanuguage Are You? 如何解释内存中的内容 好久没来了。。。 第七章: 封装 - 空气 - 博客园 C/C++中的内存管理 经典正则表达式 二叉树的显示 软件工厂的考试题目程序 测试-通过Word 2007发布Blog 第五章: 数组 第四章: 从 autoboxing 和 unboxing 认识对象 第三章: 语法入门 1. 让自己习惯C++ 0. 序
第六章: 字符串
空气 · 2006-12-10 · via 博客园 - 空气

字符串的本质是租出类型的数组,在JAVA中则将字符串视为String类的一个实例.

String 类的常用方法

Length() 长度

Equals(String s) 判断两个字符是否相等

toLowerCase() 转换为小写字母

toUpperCase() 转换为大写字母

Integer.parseInt(String s) 类型转换

Double.parseDouble(String s)

indexOf(int ch) 字符(串)查找

indexOf(String s)

lastIndexOf(Int ch)

substring(int beginIndex) 取出指定索引处至字符串末尾的字符串

substring(int beginIndex, int endIndex)

toCharArray() 转换为字符数组

声明方式:

String str = "Hello world!";

String str = new String("Hello world!");

需要注意的是,两种声明方式是有所差别的

对于一个字符串对象,一旦被配置,它的内容就是不可变的.变化的只是引用.

String str1 = "fly";

String str2 = "fly";

str1 == str2; // 返回 true

String str3 = new String("fly");

String str4 = new String("fly");

str3 == str4; // 返回 false

在J2SE5.0中,可以使用 StringBuilder 类,用法与C#类似

用法简单方便,不再赘述