But that didn’t work for me and it gave the error: “Array initializers are valid only for arrays, but the type of ‘cars’ is ‘Object'” So I guess type inference doesn’t work with array initialization. This also doesn’t work with collections or array lists – ONLY arrays.