Commit f6c0260
committed
feat: Demonstrate string comparison and concatenation methods in Java
📌 Highlights:
- Compare strings using:
- `equals()` — case-sensitive comparison.
- `equalsIgnoreCase()` — case-insensitive comparison.
- `==` — compares object references (not recommended for content comparison).
- Use `compareTo()` to perform lexicographical comparison.
- Use `contains()` to check for a substring.
- Concatenate strings using `concat()` and `+`.
🔍 Examples:
- `"Pyramid".equals("pyramid")` → false
- `"Pyramid".equalsIgnoreCase("pyramid")` → true
- `"china wall".compareTo("china tall")` → returns a positive value since `'w' > 't'`
- `"the great wall".contains("wall")` → true
- `"the great wall".concat("of china")` → combines both strings
✅ Purpose:
To explore key string operations used in real-world Java programs such as comparisons, substring checks, and joining.
Signed-off-by: Somesh diwan <[email protected]>1 parent 6042c95 commit f6c0260
1 file changed
+1
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | | - | |
28 | | - | |
29 | 26 | | |
30 | | - | |
31 | | - | |
| 27 | + | |
0 commit comments