Have students label a string’s index values to help them understand how to use Java’s substring method.

  • It is easier for students to choose the correct starting and ending arguments for substring when they have visual reference for characters and indices of the string.
  • The following is an example table containing string character values and index values.
String Values h e l l o
Index Values 0 1 2 3 4

More about this tip

Tags

External Source

Leigh Ann Sudol-DeLyser’s notes from 2009 AP CS A exam.