Question: how arraylist works in java?
Answer: When we create ArrayList this way , the ArrayList will invoke the constructor with the integer argument. It will create internally an array of Object . The size of the Object[] will be equal to the argument passed in the constructor . Thus when above line of code is executed ,it creates an Object[] of capacity 20.