on 02-28-2007 6:08 PM
Hi Group,
I have a field length of 12 character,to multiply last 12th character with 2 I am using
<b>
Integer.parseInt(a[j].substring(11,12)) * 2
</b> in Java UDF
but it is giving the error that index out of range?
Can any body suggest what is the wrong I am doing in the above statement
Hi swabap,
Use
Integer.parseInt(a[j].substring(10,11)) * 2
in Java UDF
because in java the first char starts with 0
Regards,
Akshay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
yes please use:
Integer.parseInt(a[j].substring(10,11)) * 2
as the standard format of subtring() function is:
"substring(start,end)" and in case of java the index starts from '0'
But there is one <b>more imp</b> thing that the value of a[j] should'nt be less than 12 chars and this is a must condition or it will throw an error.
If there is a possibility of the chars in a[j] will be less than 12 then u can pad it and make it 12 chars.u will need one more udf or u can use the same udf and add the padding function in it.
Ranjit.
please use..
Integer.parseInt(a[j].substring(11)) * 2
The java indexing starts from 0 ..so for a 12 character long string the last index is 11...
Thanks.
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 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.