I'm trying to allocate an IntBuffer during run-time once I know the
size I need but I can't get the following to compile. Eclipse
highlights the reason as such ...
[code]
Syntax error on token "]", VariableDeclaratorId expected after this
token.
[/code]
[code]
private IntBuffer[] indBuffers;
public void myMethod(int val) {
indBuffers[] = BufferUtils.newIntBuffer[val];
// error in above line
...
[/code]
Mark Thomas - 26 Apr 2006 20:24 GMT
> I'm trying to allocate an IntBuffer during run-time once I know the
> size I need but I can't get the following to compile. Eclipse
[quoted text clipped - 10 lines]
> public void myMethod(int val) {
> indBuffers[] = BufferUtils.newIntBuffer[val];
Leave out the [] - the name of the variable is just indBuffers.
> // error in above line
> ...
> [/code]
Mark
Oliver Wong - 26 Apr 2006 21:28 GMT
> I'm trying to allocate an IntBuffer during run-time once I know the
> size I need but I can't get the following to compile. Eclipse
[quoted text clipped - 13 lines]
> ...
> [/code]
Assuming BufferUtils.newIntBuffer is an IntBuffer[][], then you would write
something like:
<code>
indBuffers = BufferUtils.newIntBuffer[val];
</code>
but if BufferUtils.newIntBuffer is actually a method which takes a single
integer as an argument and returns IntBuffer[], then you would write
something like:
<code>
indBuffers = BufferUtils.newIntBuffer(val);
</code>
- Oliver