-3
Bu kod çalışmıyor;Koleksiyon için bir dizi enum eklenemiyor
ArrayList<BlockFace> cardinalDirections = new ArrayList<>();
cardinalDirections.addAll(new BlockFace[] {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST});
Ve bunlar da; Bir defada elle birer eleman eklemek veya dizi yineleme eğer
ArrayList<BlockFace> cardinalDirections = Arrays.asList(new BlockFace[] {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST});
sadece çalışır;
ArrayList<BlockFace> cardinalDirections = new ArrayList<>();
for (BlockFace face : new BlockFace[] {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
cardinalDirections.add(face);
Neden ilk iki örnek çalışmıyor?
'listesi cardinalDirections = Arrays.asList (yeni BlockFace [] {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}); 'yerine' ArrayList ' –
Tunaki
' addAll' bir diziyi kabul eden bir aşırı yüklenmeye sahip değil. – Savior
Ve 'Arrays.asList',' List' bir dönüş türüne sahiptir. – Savior