class Main {
public static void main(String args) {
String word = “abracadabra”;
String str = " ";
char charArray = word.toCharArray();
for(int k=0; k<word.length()-1;){
if(charArray[k] == ‘A’){
if(charArray[k+1] != ‘A’){
char holder = word.charAt(k);
char holder1 = word.charAt(k+1);
charArray[k] = holder1;
charArray[k+1] = holder;
str += word.substring(k,k+2);
k=k+2;
}
else{
str += word.charAt(k);
k=k+1;
}
}
}
System.out.println(str);
}
}
My code is taking forever to compile, can someone tell me why?
Here is the link: https://replit.com/@EphramChun/PoliteSqueakyArchives?v=1