1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class Toast { public static void reverse(int[] array) { if(array == null || array.length < 2) return; int start = 0, end = array.length - 1; while(start < end){ swap(array, start, end); start++; end--; } } } |
styled using hilite.me
No comments:
Post a Comment