Java > Warmup-1 > startHi (CodingBat Solution)

Problem:

Given a string, return true if the string starts with "hi" and false otherwise.

startHi("hi there") → true
startHi("hi") → true
startHi("hello hi") → false


Solution:

public boolean startHi(String str) {
  if (str.startsWith("hi"))
    return true;
  else
    return false;
}

2 comments:

  1. if (str.startsWith("hi")){
    return true;
    }
    return false;

    ReplyDelete
  2. Thanks for providing best java solutions. I appreciate your efforts. You can also check best iOS app development company in usa.

    ReplyDelete