Skip to content

Commit f6c0260

Browse files
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

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Section6StringClassPrinting/src/StringAB5.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
public class StringAB5 {
2-
32
public static void main(String[] args) {
43

54
String str1="Pyramid";
@@ -24,8 +23,5 @@ public static void main(String[] args) {
2423
System.out.println(str1.contains("wall"));
2524
System.out.println(str1.concat(str2));
2625
System.out.println(str1 + str2);*/
27-
28-
2926
}
30-
31-
}
27+
}

0 commit comments

Comments
 (0)