15-02-常用对象API(String类-构造函数)
来源:互联网 发布:mac听写与语音没有了 编辑:程序博客网 时间:2024/05/23 22:41
package cn.itcast.string.demo;public class StringConstructDemo {public static void main(String[] args) {stringConstructDemo2();}//用String构造器只能将两种数组能变成字符串,一种byte,一种charprivate static void stringConstructDemo2() {char[] arr = {'w','a','p','q','s'};String s = new String(arr);//将数组连成字符串String s1 = new String(arr,2,3);//从数组arr中角标为2的元素开始取,取3个元素,组成字符串System.out.println("s="+s);System.out.println("s1="+s1);}private static void stringConstructDemo(){String s = new String();//等效于String s = "";不等效String s = null;byte[] arr = {65,66,67,68};String s1 = new String(arr);//arr数组传进去,会自动根据数值查ASC码表//真正开发时候有用,许多数据可变成字节存储,因为字节单位最小,而当需要观察这些数据时,可以将其转为字符串形式,一目了然System.out.println("s1="+s1);}}
0 0
- 15-02-常用对象API(String类-构造函数)
- 01-常用对象API(String类-特点)1 2 02-常用对象API(String类-构造函数)
- 02-常用对象API(String类-构造函数),字符串中euqals比较
- String对象常用API
- 15-01-常用对象API(String类-特点)
- 15-05-常用对象API(String类-常见功能-转换)
- 15-06-常用对象API(String类-常见功能-判断)
- 15-07-常用对象API(String类-常见功能-比较)
- 15-08-常用对象API(String类-intern方法)
- 常用对象API(String类-特点)
- 4.1常用对象API(String类)
- 二十一、标准库类型string的使用、string类介绍、string对象的构造和初始化、string常用成员函数
- XMLHTTPRequest对象构造函数(常用)
- String 类构造函数
- String类常用api
- 黑马程序员 常用对象API-- String类、Stringbuffer、StringBuilder总结
- 常用对象API(String类)和 StringBuffer
- 黑马程序员《常用对象API string类 stringbuffer、stringBuilder》
- mysql主从复制
- Mac
- linux简单cpu压力工具
- 控制台下输出包含中文的wchar_t字符串的方法
- 【HDU 4763】Theme Section(KMP)
- 15-02-常用对象API(String类-构造函数)
- 《Windows核心编程》---Interlocked原子访问系列函数
- php学习笔记--trait的使用(为实现多继承产生)
- arm汇编的str指令
- atitit.系统架构图 的设计 与工具 attilax总结
- 表单防止重复提交
- 15-03-常用对象API(String类-常见功能-获取_1)
- 直方图均衡化原理和编码实现(C/C++)
- Python UnitTest 框架执行功能自动化测试