|
-
March 8th, 2000, 06:15 PM
#3
Re: Using a Switch
A rather rudimentary way, but it should probably look something like:
String message;
...
public String encodeMessage(String message){
char[] encoded = message.getChars();
for(int i = 0; i<encoded.length; i++){
switch(encoded[i]){
case('a'): encoded[i] = 'f'; break;
case('b'): encoded[i] = 'x'; break;
....
}
}
return new String(encoded);
}
Hope this helps.
Dustin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|