java - Reverse method for Array<String> -


this question has answer here:

i trying write method return playing cards (array<string>) in reverse order.

each card represented combination of : card values (a, 1-9, t, j,q,k) , suits (h=hearts, d=diamonds, c=clubs, s=spades) 10 represented t not 10 2 characters.

how write reverse method array<string> in java?

public array<string> reversedeck(array<string> deckofcards) {   } 

try this:

public arraylist<string> reversedeck(arraylist<string> deckofcards) {    arraylist<string> reverseddeck = new arraylist<string>(deckofcards.size());     for(int i=deckofcards.size()-1;i>=0;i--)        reverseddeck.add(deckofcards.get(i));     return reverseddeck; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -