How to convert char array to String in Java
来源:互联网 发布:ubuntu 软件安装路径 编辑:程序博客网 时间:2024/05/19 00:08
How to convert char array to String in Java
Use copyValueof() method to copy value from array to String object
public class CharArrayToString {
public static void main(String a[]){
char ch[] = {'M','y',' ','J','a','v','a',' ','e','x','a','m','p','l','e'};
/**
* We can copy a char array to a string by using
* copyValueOf() method.
*/
String chStr = String.copyValueOf(ch);
System.out.println(chStr);
/**
* We can also copy only range of characters in a
* char array by copyValueOf() method.
*/
String subStr = String.copyValueOf(ch,3,4);
System.out.println(subStr);
}
}
output
My Java example
Java
- How to convert char array to String in Java
- How to convert InputStream to String/convert char[] to String
- How to convert array<System::Byte> to char* in C++ CLR?
- How to: Convert System::String to wchar_t* or char*
- Swift: How to convert a String to UInt8 array?
- how to convert char to char []
- How to convert Java String into byte[]?
- How to convert std::string to LPCWSTR in C++ (Unicode)
- How to convert from int to string in objective c
- How to convert from int to string in objective c
- Convert byte array to char* in a clr wrapper
- java 字符串 转数组 Java – How to convert String into Array
- How to convert wchar_t* to char*
- How to split a string to array in objective-c?
- How to convert negative number to positive in Java?
- How to convert ArrayList to Set in Java with Example
- How to convert List<Integer> to int[] in Java?
- How to convert a Map to List in Java?
- TFT -lcd 驱动
- Ubuntu_java 环境变量(使用自安装jdk,不使用默认jdk)
- Flex Tree 默认展开首节点并选中
- Linux command to display package description, information, version and usage
- 三.单纯形方法(原理)
- How to convert char array to String in Java
- Android 使用 ANT 打包 Android 应用 .
- Android 短彩信数据模型介绍
- SpringMVC配置
- javascript技巧
- 因果图法
- 冒泡排序算法
- undefined reference to 'pthread_create'
- 记android平台下一次病毒发现之旅