- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
MyNumber(String n) {
try {
for (int i = 0; i < n.length(); i++) {
numbers[i] = charToInt(n.charAt(i));
}
} catch (InvalidArgumentException e) {
e.printStackTrace();
}
}
public int charToInt(char c) throws InvalidArgumentException{
char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
for (int i = 0; i < 10; i++) {
if (digits[i] == c) return i;
}
throw new InvalidArgumentException(null);
}