Reports redundant String constructors and calls to methods like toString() or substring() when they can be replaced with a simplified expression.

For example, calls to these methods can be safely removed in cases like "string".substring(0), "string".toString(), or new StringBuilder().toString().substring(1,3).

Example:


  System.out.println(new String("message"));

After the quick-fix is applied:


  System.out.println("message");

Note that the quick-fix removes the redundant constructor, and this may affect String referential equality. If you need to preserve it even though it is considered bad practice, suppress the warning or configure the settings to ignore redundant String constructors.

New in 2018.1