声明一个数组
String[] aArray = new String[5]; /* 创建5个内存空间 */ String[] bArray = {"a","b","c", "d", "e"}; /* 数组赋值 */ String[] cArray = new String[]{"a","b","c","d","e"};
输出数组
public class main { public static void main(String args[]) { String[] bArray = {"a","b","c", "d", "e"}; for (int i=0; i < bArray.length; i++){ System.out.println(bArray[i]); } } }
文章评论