Libgdx Array<> how to get last item?
问题 I want to change Y position of "bucket", when camera Y position is higher than "last created bucket" Y position: There is my code in "create()" method buckets = new Array<Bucket>(); for(int i=1;i<BUCKET_COUNT;i++){ buckets.add(new Bucket(world,(rand.nextInt((int)W)-45)/PPM,BUCKET_MARGIN*i/PPM)); } And I am doing like this in "render()" method: for(Bucket bucket : buckets){ if(cam.position.y > buckets.peek().getBody().getPosition().y){ bucket.repos(rand.nextInt((int)W)/PPM,buckets.size+BUCKET