Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String[] word = new String[normalWord.length()];
- String answer = "";
- for (int i = 0; i < normalWord.length(); i++) {
- if (i != normalWord.length() - 1)
- word[i] = normalWord.substring(i, i+1);
- else
- word[i] = normalWord.substring(i);
- }
- for (int j = 0; j < word.length; j += 2) {
- if (j != word.length - 1 ) {
- if (word[j].compareToIgnoreCase("A") == 0 && word[j + 1].compareToIgnoreCase("A") != 0) {
- String temp = word[j];
- word[j] = word[j+1];
- word[j + 1] = temp;
- }
- }
- else
- word[j] = word[j];
- }
- for (int z = 0; z < word.length; z++) {
- answer += word[z];
- }
- System.out.println(answer);
Advertisement
Add Comment
Please, Sign In to add comment