The problem is that you're using bitwise |
to combine characters - that's not providing multiple cases as I think you expect it to. Instead, it's just taking the Unicode values for the different characters and combining them with a bitwise-OR operation.
This will show you why you're getting the duplicate case error:
System.out.println('G' | 'H' | 'I');
System.out.println('J' | 'K' | 'L');
System.out.println('M' | 'N' | 'O');
All three lines print 79.
You really want:
case 'A': case 'B': case 'C': buf[i]='2'; break;
case 'D': case 'E': case 'F': buf[i]='3'; break;
etc
(I'd personally reformat this too, but that's a different matter. Note the break
statements too!)
You might also want to consider a Map<Character, Character>
instead of the switch statement.