当前位置:网站首页>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);
}
}
边栏推荐
- Live Classroom System 08 Supplement - Tencent Cloud Object Storage and Course Classification Management
- 带你一文读懂SaaS版多租户商城系统对多品牌企业的应用价值
- Redis Performance Impact - Asynchronous Mechanisms and Response Latency
- Likou 215 questions, the Kth largest element in an array
- 黑猫带你学Makefile第13篇:Makefile编译问题合集
- CGO Preliminary Cognition and Basic Data Type Conversion
- 数字化转型:如何引导创新领导者
- MATLAB神经网络拟合工具箱Neural Net Fitting使用方法
- 接口测试的概念、目的、流程、测试方法有哪些?
- 2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
猜你喜欢
Conditional Statements of Shell Programming (2)
ACM模板笔记:最长不下降/上升子序列
Regular expression of shell programming and text processor
xshell (sed 命令)
What are the concepts, purposes, processes, and testing methods of interface testing?
These must-know JVM knowledge, I have sorted it out with a mind map
APP UI自动化测试常见面试题,或许有用呢~
Shell programming specification and variables
内置模板市场,DataEase开源数据可视化分析平台v1.13.0发布
Future与CompletableFuture
随机推荐
力扣215题,数组中的第K个最大元素
wget编译升级故障解决
ArcMap时间滑块功能动态显示图层数据并生成视频或动图
Redis 性能影响 - 异步机制和响应延迟
C. Social Distance
Mark!画出漂亮的神经网络图!神经网络可视化工具集锦搜集
【vulhub】MySql身份认证绕过漏洞复现(CVE-2012-2122)
从斐波那契 - 谈及动态规划 - 优化
C. Even Picture
ACM解题笔记——HDU 1401 Solitaire(DBFS)
ACM模板笔记:最长不下降/上升子序列
xshell (sed command)
使用SylixOS虚拟串口,实现系统串口自由
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
DDL:视图——《mysql 从入门到内卷再到入土》
LeetCode每日一题(1573. Number of Ways to Split a String)
服务——DNS正向反向域名解析服务
LeetCode-498 - Diagonal Traversal
INSERT:插入操作语法&使用例——《mysql 从入门到内卷再到入土》
扩展中国剩余定理