### Question:
Strings { @NotNull public static String ensureStartsWith(@NotNull final String str, final char c) { if (str.length() == 0) { return Character.toString(c); } else { char c1 = str.charAt(0); if (c1 == c) return str; else return c + str; } }  @SuppressWarnings({"StringEquality", "SimplifiableIfStatement"}) static boolean eq(final String str1, final String str2); @SuppressWarnings({"StringEquality", "SimplifiableIfStatement"}) static boolean eq(final String str1, final String str2, final boolean caseSensitive); @NotNull static String ensureStartsWith(@NotNull final String str, final char c); @NotNull static String ensureEndsWith(@NotNull final String str, final char c); @NotNull static String removeEnding(@NotNull final String str, @NotNull final String ending); @NotNull static String rtrim(@NotNull final String str); @NotNull static String replace(@NotNull final String where, @NotNull final String what, @NotNull final String with); @NotNull static String repeat(@NotNull final String what, @Nullable final String delimiter, int count); @Contract("null,_->false") static boolean matches(@Nullable final CharSequence string, @NotNull final Pattern pattern); @Contract("null,_,_->false") static boolean matches(@Nullable final CharSequence string, @NotNull final String pattern, boolean caseSensitive); @Contract("!null->!null; null->null") static String upper(@Nullable final String string); @Contract("!null->!null; null->null") static String lower(@Nullable final String string); @Contract("!null->!null; null->null") static String minimizeSpaces(@Nullable final String string); @Contract("!null,_->!null; null,_->null") static String lastPart(@Nullable final String string, final char delimiter);  }### Answer:
@Test public void ensureStartsWith_basic() { assertThat(ensureStartsWith("AAAA", 'C')).isEqualTo("CAAAA"); assertThat(ensureStartsWith("CAAAA", 'C')).isEqualTo("CAAAA"); assertThat(ensureStartsWith("", 'C')).isEqualTo("C"); }
@Test public void ensureStartsWith_dontMakeNewInstanceIfAlreadyStarts() { final String str = "CAAA"; final String ensured = ensureStartsWith(str, 'C'); assertThat(ensured).isSameAs(str); }