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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
MyScale Blog
MyScale Blog
Jina AI
Jina AI
B
Blog
Microsoft Security Blog
Microsoft Security Blog
T
Troy Hunt's Blog
博客园_首页
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
GbyAI
GbyAI
T
Tenable Blog
B
Blog RSS Feed
S
Securelist
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
AWS News Blog
AWS News Blog
V
V2EX
宝玉的分享
宝玉的分享
J
Java Code Geeks
小众软件
小众软件
Spread Privacy
Spread Privacy
腾讯CDC
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
V
Visual Studio Blog
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Know Your Adversary
Know Your Adversary
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
C
Check Point Blog
Webroot Blog
Webroot Blog
D
DataBreaches.Net
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家

博客园 - 空气

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

用法简单方便,不再赘述