File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1220,6 +1220,20 @@ arr[2] = 3
1220
1220
SomeObject .myMethod (arr) // assuming the method is accepting an array of primitive types
1221
1221
```
1222
1222
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
+
1223
1237
##### Two-Dimensional Arrays of Primitive Types
1224
1238
1225
1239
The above scenario gets more tricky with two-dimensional arrays. Consider a Java method that accepts as an argument a two-dimensional array:
You can’t perform that action at this time.
0 commit comments