Java中如何使用数组
//1声明数组
int[] scores;//整型
double height[];//浮点型
String[] names;//字符型
//2分配空间
scores=new int[5];//整型
height=new double[5];//浮点型
names=new String[5];//字符型
//声明数组和分配空间合并起来
int[] scores=new int[5];
//声明,分配,赋值合并起来
int[] scores={78,56,84,96};
//它等价于:
int[] scores=new int[]{78,56,84,96};
//例子: 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = new String[5];
// 分别为数组中的元素赋值
subjects[0] = "Oracle";
subjects[1] = "PHP";
subjects[2] = "Linux";
subjects[3] = "Java";
subjects[4] = "HTML";