数组
初始化
1, int [] data = new int[3];
2 , int [] data = new int[]{1,2,3};
3, int [] data = {1,2,3};
创建
package com.kaishengit;
/**
* @author Wgs
* @version 1.0
* @create:2018/05/16
*/
public class ArrayTest {
public static void main(String[] args) {
int[] data = new int[3]; // 开辟三个空间的数组
// 为数组赋值
data[0] = 2;
data[1] = 4;
data[2] = 6;
for (int x = 0; x < data.length; x++) {
System.out.println(data[x]);
}
}
}
flag
package com.kaishengit;
import java.util.Scanner;
/**
* @author Wgs
* @version 1.0
* @create:2018/05/16
*/
public class TestDemo {
public sta