Let's say that I have an Array of size [10] and when that array get's filled up I want to implement a FIFO structure instead of it just being full and therefore not able to add new stuff to the array and throw out the old.
For example if I have a String array with car manufacturers and when I have 10 manufacturers in my array I want the oldest entry to be deleted and the newest entry to be added but kepping FIFO in mind. How would I implement that in a method like this:
public void insert(String name)
{
int a;
a = (rear + 1) % names.length;
if(a == front)
{
System.out.println("Full Queue!");
}
else
{
rear = a;
names[rear] = name;
if(front == -1)
{
front = 0;
}
}
}