about | help | code help+videos | done | prefs |
public String firstLetter(String str)
public String firstLetter(String str) { String s = str.substring(0,1); return s; }NOTE: substring(start, stop) creates (returns) a String using its 2 parameters: start and stop. The method uses 0-based indexing (the first character is at position 0. NOT 1), The start parameter specifies at which position the new string should begin. The stop parameter specifies at which position the new string should stop. The character at the stop position is NOT used. Also note that the length of the substring that is created is (stop-start)! firstLetter("abc") → "a" firstLetter("123") → "1" firstLetter("Hollow") → "H" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 10
Copyright Nick Parlante 2017 - privacy