on 04-14-2010 6:34 PM
Dear All,
Kindly let me know what am I doing wrong in the below code? I am getting errors in the UDF ...
int I_Length = 0;
int H_Count = 0;
String flag;
H_Count = I_Val.replaceAll("-","").length(); // Count all "-" in the string
I_Length = I_Val.length(); // Count the length of the string
if ( (H_Count.equals("3")) && (I_Length.equals("21")) )
flag = "x";
else flag = "y";
return flag;
"I_Val" is a variable that I am passing in the UDF. I getting error as - Error in source code.
Please help. Thanks,
--Abhi
Adding to my initial question, I noticed that the problem comes in the "if" statement as it gives error message for "de-referencing" where I check for equals() ...
When I make the "int" as "string", although even the true condition fails, but there is no error message ...
I know equals() returns a Boolean true or false, but I am surprised how this equality is not working !!
Any suggestions? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
can you try replacing this :
if ( (H_Count.equals("3")) && (I_Length.equals("21")) )
with this:
if ( H_Count == 3 && I_Length == 21 )
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.