沙盒:
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.System.*;
import static java.util.Arrays.*;
public class Sandboxx
{
public static void main( String args[] )
{
Construct ion = new Construct(3, "3, 2, 1, 0");
}
}
构造:
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.System.*;
import static java.util.Arrays.*;
public class Construct
{
int length;
String s;
public Construct() {
}
public Construct(int _length) {
}
public Construct(String _s) {
}
public Construct(int _length, String _s) {
length = _length;
s = _s;
Scanner chopper = new Scanner(s);
int[] nums = new int[3];
while (chopper.hasNextInt()) {
nums = chopper.nextInt();
}
}
}
我正在尝试将一串整数 (s) 放入整数数组 (nums) 中。我写了这段代码,但我收到了这个错误:错误:/Users/bobgalt/Construct.java:41: '.class' expected。如您所见,我是java的新手,但我似乎无法弄清楚如何将整数字符串放入整数数组中。谢谢