Could someone tell me what's wrong with this code? The result is always the 1st number before space, but it has to be the sum of all the numbers in the array.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner entrada = new Scanner(System.in);
String x = entrada.next();
String array[] = x.split (" ");
int soma = 0;
int resultado[] = new int[array.length];
for (int i = 0; i < array.length; i++) {
resultado[i] = Integer.parseInt(array[i]);
soma = soma + resultado[i];
}
System.out.println (soma);
}
}