Jtest logo




Contents  Previous  Next  Index

PB.PDS


Provide "default:" for each "switch" statement

Description

This rule flags any "switch" statement that does not have a "default" label.

Example

 package PB;
 
 public class PDS {
     void method (int i) {
         switch (i) {
         case 1:
             a = 10;
             break;
         case 2:
         case 3:
             a = 20;
             return;
         }  // missing default label
     }
 }

Repair

Add a "default" statement.


Contents  Previous  Next  Index

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