Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package codingquestionreview;
- /**
- *
- * @author Beth Irvine
- */
- public class CodingQuestionReview {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- int[] array = new int[]{1, 2, 3, 4, 5, 6};
- System.out.println("The array pre reverse: ");
- for (int i = 0; i < array.length; i++) {
- System.out.println(array[i]);
- }
- int temp;
- int left = 0;
- int right = array.length - 1;
- while (left < right) {
- temp = array[left];
- array[left] = array[right];
- array[right] = temp;
- left++;
- right--;
- }
- System.out.println("The array post reverse:");
- for (int j = 0; j < array.length; j++) {
- System.out.println(array[j]);
- }
- }
- }
Add Comment
Please, Sign In to add comment