Java > Warmup-1 > mixStart (CodingBat Solution)

Problem:

Return true if the given string begins with "mix", except the 'm' can be anything, so "pix", "9ix" .. all count.

mixStart("mix snacks") → true
mixStart("pix snacks") → true
mixStart("piz snacks") → false


Solution:

public boolean mixStart(String str) {
  if (str.startsWith("ix", 1))
    return true;
  else
    return false;
}

No comments:

Post a Comment