//There is a method using regular expression.
//usage: java CompareStr ab%cd_ abedgdfdfcd0
import java.util.regex.*;
public class CompareStr {
public static void main(String[] args) {
//to store your two strings.
String compare = args[0],
beCompare = args[1];
//translate your compare string to a regular expression.
String regex = compare.replaceAll("%", ".+").replaceAll("_", ".{1}");
System.out.println(regex);
//equal is true,or false.
boolean ifEqual = Pattern.matches(regex, beCompare);
System.out.println( compare + " equal to " + beCompare + " is: " + ifEqual);
}
}
//I'm a english learner,please correct my language error when correcting
//my programming error.