Why we cannot use array intializer after declaring an variable.
For example:
int arr[];
arr = {1,2,3,4};
But,
int arr[] = {1,2,3,4};
is correct. Is there any way to use array initialize after declaring an variable.
This is how you can.
int arr[];
arr = new int[]{1, 2, 3, 4};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With