字符数组、字节数组实例化

import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		char[] W1 = {'0','1','2','3','4'};
		byte[] W2= {65,66,67,68};
		String A = new String(W1);
		String B = new String(W1,1,3);//从下标位置为1的数开始,输出3个数
		String C = new String(W2);//按照ASCII编码进行输出
		String D = new String(W2,1,3);
		System.out.println(A);//输出01234
		System.out.println(B);//输出123
		System.out.println(C);//输出ABCD
		System.out.println(D);//输出BCD
	}

}

猜你喜欢

转载自blog.csdn.net/qq_36761831/article/details/80329188