Perhaps this is basic, but I am not quite sure I understand what is happening here:
public static void main(String[] args) throws Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
Is this instantiating an array object and immediately having it call the initializeArray method?
Comprehension check
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Nouser
4 February 2021, 08:15solution
It's declaring a reference variable that is able to point to an int array.
That's the int[] array; part.
As you already know you can declare and initialize an array in one line like
Initializing is creating the object and assigning the address, where the jvm can find the object, to the reference variable.
And you know that (siplyfiying) you can replace a method call inside the code with the methods return value.
If the method is
then
+3
Ryan Palmer
6 February 2021, 05:01
Thank you!
0