How to retrieve a variable value from inside a do while loop
<p>I am a beginner in Java and am working on a Mastermind project for a course.</p>

<p>I have a problem. I want to retrieve the value of <code>leftDigit</code> and put it into array <code>guess[4]</code>. But I don't know how to retrieve it outside the loop. </p>

<p>Let's say when I input the number 1234 and I want it to become <code>int[] guess = { 1, 2, 3, 4};</code>
`</p>

<pre><code>public static void inputNumber(){   

        Scanner input = new Scanner(System.in);
        currentRow++;

        System.out.printf ("Enter 4 numbers for attempt #%d: ", currentRow);

        int count = 10000, leftDigit;
        double tempNum;

        int number = input.nextInt();


        //finding the left digit   
        do{    
            tempNum = (double) number / count ;  
            leftDigit =  (int) (tempNum * 10) ;         
            count /=10;                         
            number = number - ( count * leftDigit);             
        } while (count != 1 );
    }
</code></pre>
