【发布时间】:2015-10-04 13:17:19
【问题描述】:
我想使用 parseInt() 方法,但我现在不知道如何将数组 a 我的代码:
import java.util.Scanner;
public class StaticMethodsWrapper {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = input.nextInt();
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
int x = Integer.parseInt(a);//here is the error
}
}
【问题讨论】:
-
不确定你在问什么。 a 已经是一个整数数组了。
-
我想将其作为数字示例:如果我输入元素:5 6 7 我想将它们作为数字来输入:567
-
既然已经把它放在了a数组中,为什么还要parseInt()呢??