System.out.println("Please enter a coefficients of a polynomial’s terms:");
String coefficents = keyboard.nextLine();
String[] three = coefficents.split(" ");
int[] intArray1 = new int[three.length];
for (int i = 0; i < intArray1.length; i++) {
System.out.print(intArray1[i]);
}
//有谁知道我是如何做到这一点的,因为不是它的构建,但是当我运行它时,它给了我0
//如果有人可以告诉我或向我解释有什么不对的帮助
答案 0 :(得分:0)
问题是您创建了数组intArray1
并且在不添加任何元素的情况下打印它。这就是为什么它会给0
作为结果。
不是创建intArray1
,而是按以下方式打印出数组three
:
import java.util.Scanner;
public class test {
public static void main(String args[]){
Scanner user_input = new Scanner(System.in);
System.out.println("Please enter the coefficients of a polynomial’s terms:");
String coefficents = user_input.nextLine();
String[] three = coefficents.split(" ");
for (String i: three) {
System.out.print(i);
}
}
}