不知道楼主想要的是从控制台输入的int类型数字吗?如果是的可以参考我这个代码:
import java.util.*;
class List
{
public static void main(String[] args)
{
Scanner list = new Scanner(System.in); //从控制台获取
int[] List = new int[3]; //定义整形数组,假设是长度为3
for (int x=0;x<List.length ;x++ ) //分别为数组赋值
{
List[x]=list.nextInt();
}
for (int x=0;x<List.length ;x++ )//输出
{
System.out.println(List[x]);
}
}
} |