1 public class CCNumber
2 {
3 public static void main(String[] args)
4 {
5 String creditCardNumber = "4123-5678-9012-3450";
6
7 int i = 0;
8 while (i < creditCardNumber.length())
9 {
10 char ch = creditCardNumber.charAt(i);
11 if (ch == ' ' || ch == "-")
12 {
13 String before = creditCardNumber.substring(0, i);
14 String after = creditCardNumber.substring(i + 1);
15 creditCardNumber = before + after;
16 }
17 else
18 {
19 i++;
20 }
21 }
22
23 System.out.println(creditCardNumber);
24 }
25 }