Those classes that you don't have to import are those classes in the java.lang package.
The JLS, Chapter 7, states:
A compilation unit automatically has access to all types declared in its package and also automatically imports all of the public types declared in the predefined package java.lang.
String, Integer, Character, Exception, and Boolean are all in the java.lang package. However, ArrayList and HashMap are in the java.util package and, as you already know, need to be imported (or they could be fully qualified) if used.