【发布时间】:2016-01-30 04:12:30
【问题描述】:
我正在尝试将字符串转换为列表。我通过用户输入获取字符串,但是每当我运行我的代码时,它都会给我这个:
输入一个数字:java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false] [组分隔符=\,][小数分隔符=.][正前缀=][负前缀=\Q-\E][正后缀=][负后缀=][NaN字符串=\Q�\E][无穷大字符串=\Q∞\E]
这是我的代码
public class ch3_15 {
public static void main(String[] args) {
int compNum, user_hund, user_ten, user_one, comp_hund, comp_ten, comp_one;
String s;
//user input
System.out.print("Enter a number: ");
Scanner input1 = new Scanner(System.in);
s = input1.toString();
//generating random number
compNum = (int) Math.random() * 1000;
System.out.println(s);
//finding the hundreds, tens, and ones place of the user number
List<String> myList = new ArrayList<String>(Arrays.asList(s.split(",")));
}
}
【问题讨论】:
-
它给出了什么错误?