So currently I have a setup where users enter a number from scanner util and I have a boolean that checks if the string entered is 4 digits and is only digits how can I create a boolean that would check it compared to another string for instance:
String pin = "6357";
what type of boolean would I have to compare the string to the one entered by user. Here is my current code checking the length go the string:
import java.security.MessageDigest;
import java.util.Scanner;
public class pin
{
public static void main( String[] args ) {
    Scanner kbd = new Scanner( System.in );
    String      pin;
    System.out.print( "Enter pin: " );
    pin = kbd.next();
    System.out.println( "Valid: " + isValid(pin) );
    System.out.println( "Is int: " + isInt(pin) );
    System.out.println( "MD5: " + md5HexString(pin) );
}
public static boolean isInt( String s ) {
    try {
        int i = Integer.parseInt( s );
        System.out.println( "Int: " + i );
        return true;
    }
    catch( Exception ex ) {
        return false;
    }
}
public static boolean isValid( String s ) {
    return s.matches( "\\d{4}" ); // must be 4 digits long
}
As can be seen this does not compare it to another existing string so what if I had something like this:
import java.security.MessageDigest;
import java.util.Scanner;
public class pin
{
   String pinnum = "6357";
public static void main( String[] args ) {
    Scanner kbd = new Scanner( System.in );
    String      pin;
    System.out.print( "Enter pin: " );
    pin = kbd.next();
    System.out.println( "Valid: " + isValid(pin) );
    System.out.println( "Is int: " + isInt(pin) );
    System.out.println( "MD5: " + md5HexString(pin) );
}
public static boolean isInt( String s ) {
    try {
        int i = Integer.parseInt( s );
        System.out.println( "Int: " + i );
        return true;
    }
    catch( Exception ex ) {
        return false;
    }
}
public static boolean isValid( String s ) {
    //what to put here?
}
In this example I pre set up a pin that I would like to check if what the user entered through scanner util matches exactly. Is this possible?
 
     
    