Below code will help you:
String cnum = "4242424242424242"
Use a for loop to extract single character and use second pointer in your question, as below:
for (char ch : cnum.toCharArray()) {
switch (Integer.parseInt(String.valueOf(ch))) {
case 1:
driver.findElement(By.id("cardNumber")).sendKeys(Keys.NUMPAD1);
break;
case 2:
//and so on...
}
}