I'm working on a project using Java and am creating an object which has a 2D array of primitive values as one of its instance variables. I'm hoping to create a method which initializes the object's instance variables in O(n) time complexity, but I'm unsure if this is possible as my understanding of 2D array initialization is that it takes O(n2), as a 2D array is essentially an array of arrays, and initializing a 1D array in Java takes O(n) time. I was hoping to confirm whether or not this belief and reasoning is correct.
Thank you in advance!