Skip to content

Commit 453c36b

Browse files
authored
chore: show array marshall using java.nio classes (#19)
1 parent b4f47b9 commit 453c36b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

advanced-concepts.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,20 @@ arr[2] = 3
12201220
SomeObject.myMethod(arr) // assuming the method is accepting an array of primitive types
12211221
```
12221222

1223+
However there are some other helpful classes we can use to create a few other arrays of primitive types
1224+
1225+
```js
1226+
const byteArray = java.nio.ByteBuffer.wrap([1]).array();
1227+
const shortArray = java.nio.ShortBuffer.wrap([1]).array();
1228+
const intArray = java.nio.IntBuffer.wrap([1]).array();
1229+
const longArray = java.nio.LongBuffer.wrap([1]).array();
1230+
const floatArray = java.nio.FloatBuffer.wrap([1]).array();
1231+
const doubleArray = java.nio.DoubleBuffer.wrap([1]).array();
1232+
```
1233+
1234+
1235+
1236+
12231237
##### Two-Dimensional Arrays of Primitive Types
12241238

12251239
The above scenario gets more tricky with two-dimensional arrays. Consider a Java method that accepts as an argument a two-dimensional array:

0 commit comments

Comments
 (0)