热门
join now

【NB】转换为字符串

编程相关3周前更新 云程
20 0 0

如果要打印一个数组的内容,就需要通过for循环来挨个遍历,逐一打印

但是Arrays提供了一个toString()方法,直接把一个数组,转换为字符串,这样方便观察数组的内容

import java.util.Arrays;

public class HelloWorld {
public static void main(String[] args) {
int a[] = new int[] { 18, 62, 68, 82, 65, 9 };
String content = Arrays.toString(a);
System.out.println(content);

}
}

【NB】转换为字符串

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...