当前位置:网站首页>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);
}
}
边栏推荐
- ArcGIS自动随机生成采样点的方法
- Alibaba and Ant Group launched OceanBase 4.0, a distributed database, with single-machine deployment performance exceeding MySQL
- 卡片盒笔记法的操作步骤
- Huawei router clock near the drainage experiment (using stream strategy)
- RTL8721DM 双频WIFI + 蓝牙5.0 物联网(IoT)应用
- 【PCBA方案设计】蓝牙跳绳方案
- Redis 性能影响 - 异步机制和响应延迟
- B. Codeforces Subsequences
- 内置模板市场,DataEase开源数据可视化分析平台v1.13.0发布
- 什么是Jmeter?Jmeter使用的原理步骤是什么?
猜你喜欢
服务——DNS正向反向域名解析服务
Rider调试ASP.NET Core时报thread not gc-safe的解决方法
The use of TortoiseSVN little turtle
快消品行业经销商协同系统:实现经销商可视化管理,提高沟通执行效率
Live Classroom System 08-Tencent Cloud Object Storage and Course Classification Management
Shell programming specification and variables
数字化转型:如何引导创新领导者
【PCBA方案设计】蓝牙跳绳方案
Using SylixOS virtual serial port, serial port free implementation system
Regular expression of shell programming and text processor
随机推荐
Redis Performance Impact - Asynchronous Mechanisms and Response Latency
C. Rotation Matching
如何保护 LDAP 目录服务中的用户安全?
labelme-5.0.1版本编辑多边形闪退
These must-know JVM knowledge, I have sorted it out with a mind map
F. Binary String Reconstruction
ENVI感兴趣区ROI文件由XML格式转为ROI格式
一篇文章教你Pytest快速入门和基础讲解,一定要看
Kubernetes Notes / Getting Started / Production Environment / Installing Kubernetes with Deployment Tools / Starting a Cluster with kubeadm / Creating a Cluster with kubeadm
【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
JVM classic fifty questions, now the interview is stable
Alibaba and Ant Group launched OceanBase 4.0, a distributed database, with single-machine deployment performance exceeding MySQL
玩转doxygen 之RT-THREAD
国内Gravatar头像的完美替代方案Cravatar
Intelligent scheme design - intelligent rope skipping scheme
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
B. Codeforces Subsequences
Conditional Statements of Shell Programming (2)
翻译科技论文,俄译中怎样效果好
管理员必须知道的RADIUS认证服务器的部署成本