当前位置:网站首页>String类的常用方法
String类的常用方法
2022-08-10 21:25:00 【黑白不纯】
一、String的构造方法
1.
public class Text {
public static void main(String[] args) {
String s = "abc";
byte[] bytes= {97,98,99};
String s1 = new String(bytes);
System.out.println(s);//结果为abc,说明已经重写了toString方法
System.out.println(s1);//自动将byte数组转换为字符串
}
}
2.
public class Text {
public static void main(String[] args) {
//将char数组的一部分转化为字符串
char[] chars = {'我','的','天'};
String s1 = new String(chars,1,2);
System.out.println(s1);
}
}
边栏推荐
- RADIUS Authentication Server Deployment Costs That Administrators Must Know
- Bedtime story | made a Bitmap and AST length system configuration
- ArcPy读取Excel时序数据、批量反距离加权IDW插值与掩膜
- 直播课堂系统09--腾讯云点播管理模块(一)
- 带你一文读懂SaaS版多租户商城系统对多品牌企业的应用价值
- B. Codeforces Subsequences
- 力扣221题,最大正方形
- [Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
- ACM解题笔记——HDU 1401 Solitaire(DBFS)
- 【Windows】你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问,这些策略可帮助保护你的电脑
猜你喜欢
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
使用SylixOS虚拟串口,实现系统串口自由
从斐波那契 - 谈及动态规划 - 优化
【PCBA scheme design】Bluetooth skipping scheme
LeetCode-402 - Remove K digits
The use of TortoiseSVN little turtle
使用 Cloudreve 搭建私有云盘
FPGA - 7系列 FPGA内部结构之Memory Resources -03- 内置纠错功能
Shell编程之条件语句(二)
数字化转型:如何引导创新领导者
随机推荐
管理员必须知道的RADIUS认证服务器的部署成本
黑猫带你学Makefile第12篇:常见Makefile问题汇总
测试代码新的规则
自组织是管理者和成员的双向奔赴
【PCBA scheme design】Bluetooth skipping scheme
ACM模板笔记:八数码问题——使用BFS+康托展开打表解决
微擎盲盒交友变现-vp_ph打开慢优化
TCL:事务的特点,语法,测试例——《mysql 从入门到内卷再到入土》
FPGA - 7系列 FPGA内部结构之Memory Resources -03- 内置纠错功能
shell编程之免交互
The use of TortoiseSVN little turtle
The perfect alternative to domestic Gravatar avatars Cravatar
Redis Performance Impact - Asynchronous Mechanisms and Response Latency
ACM模板笔记:最长不下降/上升子序列
ENVI感兴趣区ROI文件由XML格式转为ROI格式
Kerberos认证
一篇文章教你Pytest快速入门和基础讲解,一定要看
PPT的两个实用技巧
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
流程控制结构——《mysql 从入门到内卷再到入土》