Commit 28db03f
committed
feat: Add SubstringsDemo class to demonstrate Java substring(beginIndex, endIndex) method
- Created a `SubstringsDemo` class with examples using the `substring(int beginIndex, int endIndex)` method.
- Defined two sample strings:
- `alphabet = "ABCDEFG"` (indexes A:0 to G:6)
- `keyboard = "QWERTY"` (indexes Q:0 to Y:5)
- Used `alphabet.substring(1, 7)` to extract "BCDEFG", which includes characters from index 1 up to (but not including) index 7.
- Used `keyboard.substring(0, 5)` to extract "QWERT", which includes characters from index 0 up to index 5.
- Printed both results to demonstrate how substring slicing works in Java.
This commit serves as a practical illustration of extracting portions of strings using index ranges.
Signed-off-by: Somesh diwan <[email protected]>1 parent 7a38177 commit 28db03f
File tree
1 file changed
+4
-5
lines changed- Section6StringClassPrinting/Engineering Digest ED/src
1 file changed
+4
-5
lines changedLines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
0 commit comments