You should compare the string using a regular expression, for example:
str.matches("^[A-Z]{2}\\d{4}")
will give you a boolean value as to whether it matches or not.
The regular expression works as follows:
^ Indicates that the following pattern needs to appear at the beginning of the string.
[A-Z] Indicates that the uppercase letters A-Z are required.
{2} Indicates that the preceding pattern is repeated twice (two A-Z characters).
\\d Indicates you expect a digit (0-9)
{4} Indicates the the preceding pattern is expected four times (4 digits).
Using this method, you can loop through any number of strings and check if they match the criteria given.
You should read up on regular expressions though, there are more efficient ways of storing the pattern if you are worried about performance.