Inspectopedia
 
2024.3

Call to suspicious 'String' method

Warning
New
Last modified: 03 December 2024

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.