forked from IF-LK-2020/array
reverse() finished
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user