Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java multidimensional array considered a primitive or an object

Is int[][] matrix = new int[10][10]; a primitive or is it considered an object? When i send it as a parameter to a function, does it send its reference (like an object) or its value (like a primitive)?

like image 257
AndreiBogdan Avatar asked Apr 26 '26 10:04

AndreiBogdan


1 Answers

Every Java array is an Object. When you pass it as an argument, you pass a copy of the reference to the array.

like image 113
JB Nizet Avatar answered Apr 29 '26 07:04

JB Nizet