Commit 6042c95
committed
feat: Use indexOf with starting index to locate substring in Java String
🔍 Functionality:
- Finds the index of the substring `"udemy"` within `"www.udemy.com"` starting from index `4`.
- Expected output: `4`, since `"udemy"` starts at position 4 in the string.
🧰 Method Used:
- `String.indexOf(String str, int fromIndex)` — searches for the substring starting from the specified index and returns its first occurrence position.
✅ Purpose:
To demonstrate how `indexOf()` can search from a specific position within a string.
Signed-off-by: Somesh diwan <[email protected]>1 parent 1ccb405 commit 6042c95
1 file changed
+2
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
| 7 | + | |
0 commit comments