Guest User

Untitled

a guest
Sep 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. String input = "This is a test";
  2. char a = 'i';
  3. char b = 'e';
  4.  
  5. char[] chars = input.toCharArray();
  6. for(int i = 0; i < chars.length; i++) {
  7. if(chars[i] == a) {
  8. chars[i] = b;
  9. }else if(chars[i] == b) {
  10. chars[i] = a;
  11. }
  12. }
  13.  
  14. input = new String(chars);
Add Comment
Please, Sign In to add comment