Advertisement

Java Strings & Operators

Previous Lesson 170 of 176 Next
Advertisement
Lesson Overview: Concatenate and compare Strings properly with .equals(), .length(), and .toUpperCase().

Never Use == for String Content

Always compare String contents with a.equals(b) because == checks memory reference identity rather than character equality.

  • .length(), .trim(), .substring(), .contains()
  • Use StringBuilder inside loops for heavy concatenation

String Methods & Comparison (Editable — type & Run)

Advertisement

Test Yourself With Exercises

Check if string s1 equals "Admin":

if (s1. ("Admin")) { System.out.println("OK"); }
Advertisement