当前位置:网站首页>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);
}
}
边栏推荐
- UPDATE:修改数据语法使用例——《mysql 从入门到内卷再到入土》
- LeetCode-498-对角线遍历
- 服务——DNS正向反向域名解析服务
- 力扣221题,最大正方形
- shell(文本打印工具awk)
- Redis Performance Impact - Asynchronous Mechanisms and Response Latency
- 为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
- 地理探测器Geodetector软件的下载、应用与结果解读
- DDL:ALTER 修改数据库——《mysql 从入门到内卷再到入土》
- Live Classroom System 08-Tencent Cloud Object Storage and Course Classification Management
猜你喜欢

翻译科技论文,俄译中怎样效果好

Live Classroom System 09--Tencent Cloud VOD Management Module (1)

Rider调试ASP.NET Core时报thread not gc-safe的解决方法

Shell编程规范与变量

Regular expression of shell programming and text processor

Exploration and practice of the "zero trust" protection and data security governance system of the ransomware virus of Meichuang Technology

优化是一种习惯●出发点是'站在靠近临界'的地方

c语言之 练习题1 大贤者福尔:魔法数,神奇的等式

为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?

shell (text printing tool awk)
随机推荐
函数:函数删除操作语法&使用例——《mysql 从入门到内卷再到入土》
玩转doxygen 之RT-THREAD
社区分享|货拉拉通过JumpServer纳管大规模云上资产
Future与CompletableFuture
【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
力扣221题,最大正方形
智能方案设计——智能跳绳方案
2022.8.8好题选讲(数论场)
labelme-屏蔽拖拽的事件
石油化工行业商业供应链管理系统:标准化供应商管理,优化企业供应链采购流程
ArcGIS自动随机生成采样点的方法
web逆向之丁香园
ArcPy读取Excel时序数据、批量反距离加权IDW插值与掩膜
Bedtime story | made a Bitmap and AST length system configuration
Exploration and practice of the "zero trust" protection and data security governance system of the ransomware virus of Meichuang Technology
直播课堂系统08补-腾讯云对象存储和课程分类管理
【PCBA方案】电子握力测试仪方案she‘ji
翻译科技论文,俄译中怎样效果好
The use of TortoiseSVN little turtle
力扣215题,数组中的第K个最大元素