Jtest logo




Contents  Previous  Next  Index

INIT.NFS


Avoid using non-final "static" fields during the initialization

Description

This rule flags non-final "static" fields that are used during a field's initialization.

Example

 package INIT;
 public class NFS {
     static int max = 10;
     static int count = max; // violation
     int size = NFS.max;    // violation
 }

Repair

 package INIT;
 public class NFS {
     static final int MAX = 10; //declare a constant.
     static int max = 10;
     static int count = MAX; 
     int size = NFS.MAX;    
 }

Contents  Previous  Next  Index

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