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

阅读 243

2022-03-11


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
}

}


精彩评论(0)

0 0 举报