Just replace:
List<Object> list = new ArrayList<String>()
with
List<String> list = new ArrayList<String>()
or
List<Object> list = new ArrayList<Object>()
It is important here that you operate with the same data type
Or you can also use
List<?> list = new ArrayList<Object>();