Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String input = "This is a test";
- char a = 'i';
- char b = 'e';
- char[] chars = input.toCharArray();
- for(int i = 0; i < chars.length; i++) {
- if(chars[i] == a) {
- chars[i] = b;
- }else if(chars[i] == b) {
- chars[i] = a;
- }
- }
- input = new String(chars);
Add Comment
Please, Sign In to add comment