I know replacing a char with a string can't be done, but I'm trying to make a morse code translating program and I have two arrays one with the letters and one with the morse code translation! I have used StringTokenizer and I want to take every character of a word and replace it with the translation of the character in morse code! how can this be done?
Here is the part of code that really matters:
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (isWord(token)) {
for (int j = 0; j < token.length(); j++) {
char ch = token.charAt(j);
for (int k=0; k<26; k++){
if (ch==((char)letter[k])){
ch=(char)morse[k];
}
}
}
System.out.print(token);
}
}