My java code is taking forever to compile

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);
str += word.charAt(k);

My code is taking forever to compile, can someone tell me why?
Here is the link:

I think you’ve created an infinite loop, as you don’t have anything in the increment portion of your loop. I know you increment k within your loop, but those increments are getting reached:

Since the else block is actually “related” to the second if block ( if (charArray[k+1]… , and you have no capital A in your charArray , if(charArray[k] == 'A') is always false, and so none of the code in your loop will execute.