forked from IF-LK-2020/array
reverse() finished
This commit is contained in:
parent
15d53c68cf
commit
605a6d2a62
|
@ -308,7 +308,14 @@ public class Arrays {
|
|||
* <code>["String 2","String 1"]</code>.
|
||||
*/
|
||||
public String[] reverse( String[] pArray ) {
|
||||
return null;
|
||||
if( pArray.length == 0 ) {
|
||||
return new String[0];
|
||||
}
|
||||
String[] reverse= new String[pArray.length];
|
||||
for(int i=0;i<pArray.length;i++){
|
||||
reverse[pArray.length-1-i]=pArray[i];
|
||||
}
|
||||
return reverse;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue