Дженериковые массивы создаются чуть более правильным образом
This commit is contained in:
parent
fdd140a179
commit
89ab094b5b
@ -1,15 +1,16 @@
|
|||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class EntityWithExtraCreator <T extends EntityLocomotive, U extends IDrawningExtra> {
|
public class EntityWithExtraCreator <T extends EntityLocomotive, U extends IDrawningExtra> {
|
||||||
private EntityLocomotive[] entityArr;
|
private T[] entityArr;
|
||||||
private IDrawningExtra[] extraArr;
|
private U[] extraArr;
|
||||||
|
|
||||||
int entitiesCount = 0;
|
int entitiesCount = 0;
|
||||||
int extraCount = 0;
|
int extraCount = 0;
|
||||||
|
|
||||||
public EntityWithExtraCreator(int countEntities, int countExtra) {
|
public EntityWithExtraCreator(int countEntities, int countExtra) {
|
||||||
entityArr = new EntityLocomotive[countEntities];
|
entityArr = (T[]) new EntityLocomotive[countEntities];
|
||||||
extraArr = new IDrawningExtra[countExtra];
|
extraArr = (U[]) new IDrawningExtra[countExtra];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T entityLocomotive) {
|
public int Insert(T entityLocomotive) {
|
||||||
|
Loading…
Reference in New Issue
Block a user