Jtest logo




Contents  Previous  Next  Index

INTER.NCL


Single character literals should only be placed in constants in an internationalized environment

Description

This rule flags single character literals in non-constants.

If code contains single character literals that are used in non-constants, it will not run in an internationalized environment. This means single character literals can only be used when declared as "static" "final" "char".

Example

 package INTER;
 public class NCL{
  public void Echo() {
   System.out.println('c');  //violation
   }
 }

Repair

 package Inter;
 public class NCL{
   public void Echo(){
     System.out.println(mychar);
    }
 }
 static final char mychar ='c';
 }

Reference

http://java.sun.com/docs/books/tutorial/i18n/


Contents  Previous  Next  Index

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