You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dobes Vandermeer <do...@dobesland.com> on 2004/09/05 07:03:48 UTC
Accessing primitive arrays
I've been searching for a while, but I haven't figured out how to access
the contents of primitive arrays.
I have an int[] and I'd like to be able to fetch values out of it.
So far I've determined that []'s is a syntax error, and using .get() as if
the array were a collection doesn't seem to work either.
Any idea how this is to be done? I have a feeling I will eventually face
a situation where I can't shuffle my variables around enough to avoid
using the array directly...
Thanks,
Dobes
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Accessing primitive arrays
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Dobes,
> I've been searching for a while, but I haven't figured out how to access
> the contents of primitive arrays.
>
> I have an int[] and I'd like to be able to fetch values out of it.
>
> So far I've determined that []'s is a syntax error, and using .get() as if
> the array were a collection doesn't seem to work either.
>
> Any idea how this is to be done? I have a feeling I will eventually face
> a situation where I can't shuffle my variables around enough to avoid
> using the array directly...
I couldn't find anything, either. If you must use an array, I think it
would be easiest to make a tool for the access.
Something like:
public class ArrayTool {
public Object get(int[] ints, int index) {
return new Integer(ints[index]);
}
}
so you can $arrays.get($primitiveArray, 3).
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai(shinobu.kawai@gmail.com)
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org