Дженериковые массивы создаются чуть более правильным образом

This commit is contained in:
Данила Мочалов 2022-10-24 10:58:46 +04:00
parent fdd140a179
commit 89ab094b5b

View File

@ -1,15 +1,16 @@
import java.lang.reflect.Array;
import java.util.Random;
public class EntityWithExtraCreator <T extends EntityLocomotive, U extends IDrawningExtra> {
private EntityLocomotive[] entityArr;
private IDrawningExtra[] extraArr;
private T[] entityArr;
private U[] extraArr;
int entitiesCount = 0;
int extraCount = 0;
public EntityWithExtraCreator(int countEntities, int countExtra) {
entityArr = new EntityLocomotive[countEntities];
extraArr = new IDrawningExtra[countExtra];
entityArr = (T[]) new EntityLocomotive[countEntities];
extraArr = (U[]) new IDrawningExtra[countExtra];
}
public int Insert(T entityLocomotive) {