I hope, the snippet below might resolve the issue.
String msg = "Invalid password entered. You have {0,number,integer} {0,choice, 1#attempt|1<attempts} remaining.";
int attemptCount = 1;
System.out.println(MessageFormat.format(msg, attemptCount, attemptCount));
the result is,
Invalid password entered. You have 1 attempt remaining.