Java Palindrome, with scanner
<p>I've already completed this project for my class without using the scanner function.  But, while I was reading and researching, I read about the scanner and it seemed that it could make the coding easier and more efficient.  However, I couldn't figure out how to make it work so if anyone could give some insight into this, it would be much obliged.</p>

<pre><code>public class Palindrome {


//Controls program execution
public static void main(String[] args) {
    // Use Main to call other methods to perform the functions of checking user input for palindrome

    int testNum = retrieveInput(0);
    boolean isPalindrome = palCheck(testNum);
    display(testNum, isPalindrome);
}

//prompt and retrieve user input and check if 
//entry is numeric and is 5 numbers long
public static int retrieveInput(int testNum) {
    String userInput = JOptionPane.showInputDialog("Enter a 5-digit number");
    int StringLength = userInput.length();
    try { 

            testNum = Integer.parseInt(userInput); 
        }

    catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null, "Please enter only numbers.");
            return retrieveInput(testNum); 
        }
    if (StringLength == 5)
        return testNum;
    else
        JOptionPane.showMessageDialog(null, "Please enter exactly 5 digits.");
        return retrieveInput(testNum);

    }

//check if number is palindrome or not
public static Boolean palCheck(int testNum) {
    int isPalindrome = testNum;
    int rev = 0;
    while (isPalindrome != 0){
        int remainder = isPalindrome % 10;
        rev = rev * 10 + remainder;
        isPalindrome = isPalindrome/10;

    }
    if (testNum==rev)
        return true;
    else
        return false;
}

//display results to user
public static void display(int testNum, boolean palCheck){
    JOptionPane.showMessageDialog(null, testNum + " is" + ( palCheck ? " " : "not ") + "a palindrome.");
}
</code></pre>

<p>}</p>

<p>That is my completed and turned in assignment and the following is my crack at using the scanner</p>

<pre><code>public class Palindrome {

/**
 * @param args
 */


//Controls program execution
public static void main(String[] args) {
    // Use Main to call other methods to perform the functions of checking user input for palindrome or not

    String testNum = retrieveInput();
    boolean isPalindrome = palCheck(testNum);
    display(testNum, isPalindrome);


}

//prompt and retrieve user input and check if 
//entry is numeric and is 5 numbers long
public static String retrieveInput() {
    Scanner testNum = new Scanner(System.in);
    JOptionPane.showInputDialog("Enter a 5-digit number");
    try { 
            return testNum.next("\\d\\d\\d\\d\\d"); 
        }

    catch(Exception ex)
        {
        JOptionPane.showMessageDialog(null, "Please enter a 5-digit number!");
        return retrieveInput(); 
        }
    }

//check if number is palindrome or not
public static Boolean palCheck(String testNum) {
    StringBuilder sb = new StringBuilder(testNum).reverse();
    return testNum.equals(sb.toString());
}

//display results to user
public static void display(String testNum, boolean isPalindrome) {
    JOptionPane.showMessageDialog(null, testNum + " is" + (isPalindrome ? " " : " not ") + "a palindrome.");
}
</code></pre>

<p>}</p>

<p>My main problem lies within the retrieveInput() as I believe the rest of the code works however I can't even get the retrieveInput to function correctly (IE, won't list my error message, reloop the method, or even display anything.</p>
