Bootstrap

JAVA中字符串的转换功能

*public byte[] getBytes():以平台的默认编码集将字符传数据转换成字节数组
 * public byte[] getBytes(Charset charset):
 * public char[] toCharArray():将字符串转化为字符数组
 * public String toLowerCase():将字符串数据转换成小写
 * public String toUpperCase():将字符串数据转换成大写
 * 
 * 将任意类型转换成字符串
 * public static String valueof(int a)
 * public static String valueof(char a)
 * 
 * 字符串截取:
 * public String substring(int beginIndex)//从指定位置处开始截取到末尾
 * public String substring(int beginIndex,int endIndex)//包前不包后

public class StringDemo {
	public static void main(String[] args) {
		//定义一个字符串
		String s="Java hello world";
//		public byte[] getBytes():以平台的默认编码集将字符传数据转换成字节数组
		byte arr[]=s.getBytes();
		for(int x=0;x<arr.length;x++) {
			System.out.println(arr[x]);
		}
		char ch[]=s.toCharArray();
		for(int i=0;i<ch.length;i++) {
			System.out.println(ch[i]);
		}
		System.out.println("-------------");
		
	}
}

 

;