It sounds like you want a random number from 0 to 9 and then add it to '0', I'd use Random.nextInt(10) to get such a number,
Random rand = new Random();
int ch = '0' + rand.nextInt(10);
System.out.printf("'%s' = %d (dec), %s (hex)%n",
String.valueOf((char) ch), ch,
Integer.toHexString(ch));
Since it's difficult to debug random code, I also wrote a simple unit test,
for (int ch = '0'; ch <= '9'; ch++) {
System.out.printf("'%s' = %d (dec), %s (hex)%n",
String.valueOf((char) ch), ch,
Integer.toHexString(ch));
}
Output is
'0' = 48 (dec), 30 (hex)
'1' = 49 (dec), 31 (hex)
'2' = 50 (dec), 32 (hex)
'3' = 51 (dec), 33 (hex)
'4' = 52 (dec), 34 (hex)
'5' = 53 (dec), 35 (hex)
'6' = 54 (dec), 36 (hex)
'7' = 55 (dec), 37 (hex)
'8' = 56 (dec), 38 (hex)
'9' = 57 (dec), 39 (hex)
System.out.println(chLen); System.out.println(b); System.out.println((char)b);and the first and last output should be the same while the middle input should be different.