I’ve tried comparing this to examples and I just can’t seem to find out why this will not compile so I was hoping for some insight.
ArrayList<Integer> listOfPrimeNumbers(initialCapacity) = new ArrayList<Integer>( );
is my code. My understanding is that its creating a new ArrayList object, of type Integer which is called listOfPrimeNumbers and has an initial capacity of the argument I am passing in which is called initialCapacity.
Unfortunately I get a “‘;’ expected” error when I try and compile this ? Could someone please help ?
This is correct:
Do you see why? The first bit declares the static type of the reference; the second bit is the name of the reference; the third calls the constructor and initializes the memory.
I might recommend that you think about coding it this way: