Jtest logo




Contents  Previous  Next  Index

INTER.NSL


String literals should only be placed in constants in an internationalized environment

Description

This rule flags string literals that are not placed in constants.

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

Example

 package INTER;
 
 public class NSL{
    public void Echo () {
       System.out.println("hello");    //Violation
    }
 } 

Repair

 package Inter;
 
 public class NSL{
   public void Echo(){
    System.out.println(string1);
  }
  static final String string1="hello";
 }

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