Search

Wednesday 7 June 2017

startHi

Problem:

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

Test Cases:

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

Solution:

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

No comments:

Post a Comment