A slice is inclusive of the starting index and exclusive of the ending index.
public static String slice(String s) {
return s.substring(2, 5);
}
| Function Call | Return Value | |||
|---|---|---|---|---|
| slice("Garage") | → | |||
| slice("Track") | → | |||
| slice("556843") | → | |||
| slice("Elephant") | → | |||
| slice("Violets") | → | |||
Experiment with this code on Gitpod.io