Java > String-1 > nonStart (CodingBat Solution)

Problem:

Given 2 strings, return their concatenation, except omit the first char of each. The strings will be at least length 1.

nonStart("Hello", "There") → "ellohere"
nonStart("java", "code") → "avaode"
nonStart("shotl", "java") → "hotlava"


Solution:

public String nonStart(String a, String b) {
  return a.substring(1,a.length()) + b.substring(1,b.length());
}

3 comments: