Runtime error in Java 1.7 test 2 help me please
import java.util.Scanner;
public class _1370 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int digitos = in.nextInt();
int cliques = in.nextInt();
String saida = "";
String parte2 = "";
for (int i = 1; i <= cliques; i++){
saida += in.nextInt();
}
for (int i = cliques+1; i <= digitos; i ++){
parte2 += in.nextInt();
}
parte2 += saida;
System.out.println( parte2.substring(0,10) );
}
}
Re: Runtime error in Java 1.7 test 2 help me please
Posted by
Sahadev 14 Jul 2015 22:30
you are using in.nextInt() to get the input from the user for a String. That is used for integers. You should be using in.next() or in.nextLine() for String.