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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 最新话题
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
L
Lohrmann on Cybersecurity
博客园 - 【当耐特】
P
Privacy & Cybersecurity Law Blog
V2EX - 技术
V2EX - 技术
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cloudbric
Cloudbric
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
Webroot Blog
Webroot Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
The Hacker News
The Hacker News
MyScale Blog
MyScale Blog
Vercel News
Vercel News
B
Blog RSS Feed
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
博客园 - 三生石上(FineUI控件)
D
Docker
O
OpenAI News
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
AI
AI
T
Tor Project blog
Project Zero
Project Zero
H
Heimdal Security Blog
Latest news
Latest news
NISL@THU
NISL@THU

博客园 - 空气

没有不可能的事情 迅景如梭,旧游似梦,烟水程何限 [转]一些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#类似

用法简单方便,不再赘述