字符串数组输出

@Test
public void testA(){

String[] arr1 = new String[]{"B","A","H","E"};
// String[] arr1 = DataUtils.sortArray(arr);
//第一种方式
for (int i = 0; i < arr1.length; i++) {
System.out.println(arr1[i]);
}

//第二种方式
StringBuffer sbf = new StringBuffer("");
for (String str:arr1) {
sbf.append(str).append(",");
}
System.out.println(sbf.toString());
//第三种方式
System.out.println(Arrays.toString(arr1));
}

 

posted @ 2021-07-07 08:49  凉了记忆  阅读(594)  评论(0编辑  收藏  举报