I am trying to create
ArrayList myList = new ArrayList();
in Java but that does not work.
Can someone explain
that's because int is a primitive, it is a known issue.
If you really wanted to, you can subclass/write your own collection that can do that.