Scanner entrada=new Scanner(System.in);
System.out.println("Introduce un numero!");
String tex=entrada.nextLine();
char[] caracteres=tex.toCharArray();
int[] numeros=new int[caracteres.length];
for (int i=0; i<caracteres.length; i++){
numeros[i]=caracteres[i];
System.out.println(caracteres[i]);
System.out.println(numeros[i]);
}
The previous code gives me the result:
Enter a number! 123
1
49
2
50
3
51
Actually I have no idea why I get this result, basically what I want is to store the input of the user in an array of whole numbers, but in another part of the code I was giving the error that the index is out from the array, thanks in advance.