velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <shinobu.ka...@gmail.com>
Subject Re: Accessing primitive arrays
Date Mon, 06 Sep 2004 16:23:40 GMT
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


Mime
View raw message