Reverse an Array in Java Without Using Built-in Methods

Reversing an array is a classic problem often asked in Java interviews. In this tutorial, we'll reverse an array manually without using Collections.reverse() or Arrays utility classes.

๐Ÿงฎ Logic

We use two pointers: one starting from the beginning, and one from the end. Swap their values while moving toward the center.

✅ Java Program


public class ReverseArray {
    public static void main(String[] args) {
        int[] arr = {10, 20, 30, 40, 50};

        System.out.println("Original Array:");
        printArray(arr);

        reverseArray(arr);

        System.out.println("Reversed Array:");
        printArray(arr);
    }

    static void reverseArray(int[] arr) {
        int start = 0, end = arr.length - 1;
        while (start < end) {
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end--;
        }
    }

    static void printArray(int[] arr) {
        for (int num : arr) {
            System.out.print(num + " ");
        }
        System.out.println();
    }
}

๐Ÿง  Interview Tip

This question is often followed by variations like "reverse only even elements" or "reverse using recursion." Make sure to explain your swap logic clearly.

✅ Output

Original Array:
10 20 30 40 50 
Reversed Array:
50 40 30 20 10 

๐Ÿ“Œ Conclusion

We learned how to reverse an array in Java using simple loop logic and without relying on any built-in methods. This program builds your core understanding of arrays and data manipulation.

๐Ÿ”„ Master Array Traversal & Two-Pointer Techniques

Reversing an array is one of the most fundamental Java problems and a common starting point for mastering two-pointer and in-place algorithms. Strengthen your array problem-solving skills by exploring these closely related Java programs and interview resources.

๐Ÿง  Java Coding Round Questions

Practice array-based logic problems frequently asked in coding rounds.

✅ Check if Array Is Sorted

Learn how traversal logic is reused in array order validation.

๐Ÿšซ Remove Duplicates from Array

Understand how reversed or sorted arrays affect duplicate removal strategies.

๐Ÿ” Find Duplicates in Array

Practice scanning arrays using efficient traversal techniques.

๐Ÿฅˆ Second Largest Element in Array

Apply traversal logic to find constrained values in arrays.

๐Ÿ“Š Sort Array Without Built-ins

Learn sorting techniques often combined with array reversal.

๐Ÿ“ฆ Java Collections Interview Questions

Understand differences between arrays and collection traversal.

๐ŸŽฏ Java Interview Questions (Freshers)

Common interview questions involving arrays and traversal logic.

๐Ÿงช Advanced Java Programs (Real-World)

Apply array manipulation logic in real-world Java scenarios.