I am trying to get the value of string and integer so I can make use of that. I have taken the value and trying to store in array and then printing the value. For some reason I am not getting the value of string correctly. Can you please help me to make my code correct.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
int [] numbers = new int[r];
String names[] = new String[r];
for(int i=0; i<r; i++){
numbers[i] += sc.nextInt();
names[i] += sc.next();
}
System.out.println(Arrays.toString(numbers));
System.out.println(Arrays.toString(names));
}
Output : [2,2]
[nullAA, nullBB]
And also How can I get the indexes of both the arrays after print statement.