Jtest logo




Contents  Previous  Next  Index

OPT.STR


Use ' ' instead of " " for one character string concatenation

Description

This rule flags code that uses "" for string concatenation with one character.

Using `' instead of "" for one character string concatenation will improve performance.

Example

 package OPT;
 public class STR {
     public void method(String s) {
         String string = s + "d"  // violation.
         string = "abc" + "d"      // violation.
     }
 }

Repair

Replace one character String Constant with ' '.

 package OPT;
 public class STR {
     public void method(String s) {
         String string = s + 'd'
         string = "abc" + 'd'
     }
 }

Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft