You really should do some research on your own first (and if you have, show evidence). However, here is a solution.
int halfLength = onlyArr.length / 2 + (onlyArr.length % 2);
for(int i = 0; i < halfLength; i++){
System.out.printf("%c,%d%n", onlyArr[i], (int)(onlyArr[i + halfLength] - 48));
}
When printing the integer, you have to subtract the ascii value of ‘0’ (48) from the character and then cast the result to an int.
The assignment of halfLength
could potentially be optimised, but this code will do what you want it to do.
solved How to print characters and integers from a char array [closed]