Reputation: 4829
Variable :
Stack<Entity> entityStack = new Stack<Entity>();
It has following values :
sub_sub_sub1
sub_sub1
sub1
root1
I want these values in another stack (or list) in reverse order :
root1
sub1
sub_sub1
sub_sub_sub1
I have applied simple logic to reverse it :
for (int itr = entityStack.size()-1; itr >= 0; itr--) {
entityStackTemp.push(entityStack.get(itr));
}
Is there any in-built method of collection to achieve this considering performance of execution ?
Upvotes: 3
Views: 834