Java Array Custom Function

I want to convert a Vector3f array directly from array to another kind of data. Here is an example:

Vector3f[] vecArray = new Vector3f[10];
float[] floatArray = vecArray.toFloats(); // <<

Is that possible ?

Jon Skeet
people
quotationmark

No, there's nothing you can do to make that compile. (There's no equivalent of the extension methods in C# which would allow it, for example.)

The closest you'd be able to come would be to have a static method somewhere - whether within Vector3f or not - which you could invoke with a static import potentially:

import static ...Vector3f.toFloats;

Vector3f[] vecArray = new Vector3f[10];
float[] floatArray = toFloats(vecArray);

people

See more on this question at Stackoverflow