Project Euler#61: Cyclical figurate numbers
boolean flag = false;//FLAG flag to use as a stepback conjugate
boolean stepback = false;
do {
    flag = false;//FLAG
    if (count &lt; n - 2) {
        for (; i &lt; 9999; i++) {
            if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
                if (count == -1 || (count &gt;= 0 &amp;&amp; i / 100 == a[count] % 100) &amp;&amp; i &gt; 1000) {
                    ++count;
                    a[count] = i;
                    break;
                } else {
                    figurateStack.pop();
                }
            }
        }
    } else {
        i = (i % 100) * 100 + a[0] / 100;
        if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
            ++count;
            a[count] = i;
            break;
        } else {
            stepback = true;
        }
    }
    if (i == 9999) {
        stepback = true;
    }
    if (stepback) {
        figurateStack.pop();
        i = a[count] + 1;
        --count;
        flag = true;//FLAG
        stepback = false;
    }
    if (count &lt; n - 2 &amp;&amp; !flag) {//FLAG
        i = 100 * (i % 100) + 10;
        flag = false;//FLAG
    }
} while (count &lt; 6);
return a[0] + a[1] + a[2] + a[3] + a[4] + a[5];


You've got a flag variable in there. But from what I see, you don't need it. I've labeled all the usages with //FLAG.

The only line that sets flag to true is inside the if statement stepback. stepback is triggered by i == 9999 or some other condition earlier.

flag is set to false at the top of your do-while loop. So every iteration, it's set to false.

Because of this, the flag variable cannot be changed from false until the stepback if-statement.

So we can do this:

    if (stepback) {
        figurateStack.pop();
        i = a[count] + 1;
        --count;
        flag = true;//FLAG
        stepback = false;
    } else if (count &lt; n - 2) {
        i = 100 * (i % 100) + 10;
        flag = false;//FLAG
    }


if stepback occured, flag is true, and the if statement thereafter becomes always false. So turn it into an else.

You don't make any other checks for flag, so now flag can be removed.

boolean stepback = false;
do {
    if (count &lt; n - 2) {
        for (; i &lt; 9999; i++) {
            if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
                if (count == -1 || (count &gt;= 0 &amp;&amp; i / 100 == a[count] % 100) &amp;&amp; i &gt; 1000) {
                    ++count;
                    a[count] = i;
                    break;
                } else {
                    figurateStack.pop();
                }
            }
        }
    } else {
        i = (i % 100) * 100 + a[0] / 100;
        if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
            ++count;
            a[count] = i;
            break;
        } else {
            stepback = true;
        }
    }
    if (i == 9999) {
        stepback = true;
    }
    if (stepback) {
        figurateStack.pop();
        i = a[count] + 1;
        --count;
        stepback = false;
    } else if (count &lt; n - 2) {
        i = 100 * (i % 100) + 10;
    }
} while (count &lt; 6);
return a[0] + a[1] + a[2] + a[3] + a[4] + a[5];


Next, we can collapse the if statement i == 9999 to be included in the stepback check:

Instead of 

    if (i == 9999) {
        stepback = true;
    }
    if (stepback) {


We just do

    if (stepback || i == 9999) {


Because stepback disables itself, we don't need to worry about previous iterations of the while loop having stepback = true. 

There's also an explicit else that we can make implicit...

        if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
            ++count;
            a[count] = i;
            break;
        } else {
            stepback = true;
        }


to

        if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
            ++count;
            a[count] = i;
            break;
        } 
        stepback = true;


Making the total code

boolean stepback = false;
do {
    if (count &lt; n - 2) {
        for (; i &lt; 9999; i++) {
            if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
                if (count == -1 || (count &gt;= 0 &amp;&amp; i / 100 == a[count] % 100) &amp;&amp; i &gt; 1000) {
                    ++count;
                    a[count] = i;
                    break;
                } else {
                    figurateStack.pop();
                }
            }
        }
    } else {
        i = (i % 100) * 100 + a[0] / 100;
        if (isSpecialFigurate(i, low_lim, low_lim + (n - 1))) {
            ++count;
            a[count] = i;
            break;
        }
        stepback = true;
    }
    if (stepback || i == 9999) {
        figurateStack.pop();
        i = a[count] + 1;
        --count;
        stepback = false;
    } else if (count &lt; n - 2) {
        i = 100 * (i % 100) + 10;
    }
} while (count &lt; 6);
return a[0] + a[1] + a[2] + a[3] + a[4] + a[5];