I am trying to create
ArrayList myList = new ArrayList();
in Java but that does not work.
Can someone explain
You could try TIntArraList from GNU Trove which will act like an ArrayList of int values.