Lana Rhodes™
JCHJava Community | Help. Code. Learn.
•Created by Lana Rhodes™ on 9/30/2024 in #java-help
Simple Infinite loop help
I have the following display() method for a circular queue, but I can't find the reason why it goes into an infiti loop when rear is 2 and front is 3 when the MAX_SIZE is 5.
```java
public void display() {
System.out.println("Front: " + front);
System.out.println("Rear: " + rear);
System.out.println("Array : ");
System.out.println(" : ");
int Cfront = front;
if(front==-1)
Cfront++;
int i=0;
for(i = Cfront; i != rear;i++){
if(i==MAX_SIZE){
System.out.println("true");
i=0;
}
System.out.println(queue[i]);
}
System.out.println(queue[i]);
}
5 replies