You code can be easily generalized. Try, for instance
class Main
{
public static String build(int letters, int length)
{
StringBuilder sb = new StringBuilder();
for (int n=0; n<length; ++n)
{
sb.append((char)('M'+ n % letters));
}
return sb.toString();
}
public static void main( String args[])
{
String msg1 = build(2, 4);
String msg2 = build(3, 4);
System.out.printf("msg1 '%s', msg2 '%s'\n", msg1, msg2);
}
}