Commit 857698e
committed
feat: Convert string to char array and modify first character
🔍 What this code does:
- Takes the string `"hello"` and converts it to a character array using `toCharArray()`.
- Modifies the first character (`'h'`) to `'j'`.
- Reconstructs a new string from the modified array.
- Prints the result: `"jello"`.
✅ Why:
This approach demonstrates how to modify specific characters in a string since strings in Java are immutable.
Signed-off-by: Somesh diwan <[email protected]>1 parent 9a3d2c4 commit 857698e
1 file changed
+4
-5
lines changed| 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 | + | |
0 commit comments