+ 2
Why array is using new ?
when array is declared a new word is used in Java
2 Answers
+ 8
It allocates the memory that will hold the array. Usually, if you hate the new keyword, and know the exact elements, you can use the shortcut method, like:
int[] arr = {4, 5, 6, 7};
You are explained the 'new' keyword here in detail:
https://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html
0
You need "new" keyword if you want to use an array without initialising it. It provides the compiler a heads up to how much memory it might require