Delete Object of arraylist in LIBGDX

0
private List<LadrilloVERDEEntity> LadrilloVERDElist = new  ArrayList<LadrilloVERDEEntity>();
LadrilloVERDElist.add(new LadrilloVERDEEntity(world, ladriVerdeTexture,10,3));
LadrilloVERDElist.remove(1);// Acá es donde me marca error

I would like to delete the first created object.

    
asked by Hans Leo Quiroz Marroquin 12.07.2016 в 19:03
source

1 answer

1

Keep in mind some things:

1.- In java the first index of a list (or array) is zero:

private List LadrilloVERDElist = new  ArrayList();
LadrilloVERDElist.add(new LadrilloVERDEEntity(world, ladriVerdeTexture,10,3));
LadrilloVERDElist.remove(0);// el primer índice es el cero no el uno

2.- In libgdx it is better to use the own classes of the library (so that you can carry the game), I recommend instead of using the class List uses the Array class available in the package com.badlogic.gdx.utils

    
answered by 16.07.2016 в 01:00