Back to Intellij Community

CallToSuspiciousStringMethod

java/java-impl/resources/inspectionDescriptions/CallToSuspiciousStringMethod.html

2025.3-rc-2401 B
Original Source

Reports calls of:

  • equals()
  • equalsIgnoreCase()
  • compareTo()
  • compareToIgnoreCase() and
  • trim()

on String objects. Comparison of internationalized strings should probably use a java.text.Collator instead. String.trim() only removes control characters between 0x00 and 0x20. The String.strip() method introduced in Java 11 is more Unicode aware and can be used as a replacement.