List<String> strings = new ArrayList<>(); ---> not accepted; ArrayList<String> = new ArrayList<>(); ----> Accepted; I don't think it's something wrong with the first type of declaration.