How to avaoid java.lang.IllegalArgumentException: No enum const class
912973May 17 2012 — edited May 21 2012HI ,
Iam getting java.lang.IllegalArgumentException when iam using switch case through Enum contants.
//Enum Constants declaration
public enum USEOFPROCEEDSVALUES { U1,U2,U3, U4}
//Using Enum in Java class
Test.java
USEOFPROCEEDSVALUES useOfProceedsVar =USEOFPROCEEDSVALUES.valueOf(useOfproceeds);
switch (useOfProceedsVar) {
case U1:
revenueSourceCode="REVENUE_SOURCE_CODE.POWER";
break;
case U2:
revenueSourceCode="REVENUE _SOURCE_CODE.WATER";
break;
case U3:
revenueSourceCode="REVENUE_SOURCE_CODE.POWER";
break;
case U4:
revenueSourceCode=REVENUE_SOURCE_CODE.POWER";
}
break;
default:
revenueSourceCode=null;
Exception raising if there is either of these not U1,U2,U3,U4 ara not avalabele. i.e is if useOfProceedsVar is A6 then exception raising
How to avoid this exception
Thanks for early reply