(length:3); error

Hi,

I’m following the Algorithms Course part 1.

I keep getting this error: “length cannot be resolved to a variableJava(33554515)”.

My Code:

public class Main {
public static void main(String args) {
Array numbers = new Array(length:3);
numbers.print();
}
}

I can’t figure out what I’m doing wrong since my code is the same as Mosh’s.

Thank you.

Don’t type the parameter names when passing arguments to constructors or functions. So instead of new Array(length:3) just type new Array(3).

Thank you for your reply. Why is Mosh teaching like this if it doesn’t work?

Mosh did neither type the parameter names nor did he tell you to do so. And as you have corrected you source code now you should have noticed that the IDE displays these parameter names to make the code more readable.

1 Like

Ok. understood. Thanks.