reverse() finished

This commit is contained in:
artem.didytschuk
2020-08-31 23:08:17 +02:00
parent 15d53c68cf
commit 605a6d2a62

View File

@@ -308,7 +308,14 @@ public class Arrays {
* <code>["String 2","String 1"]</code>. * <code>["String 2","String 1"]</code>.
*/ */
public String[] reverse( String[] pArray ) { 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;
} }
/** /**