Swap Last and First Elements

import java.util.Arrays; 
 public class ArrayMethods {
 public static void main(String[] args)
 {
    int[] array_nums = {20, 30, 40};
	System.out.println("Original Array: "+Arrays.toString(array_nums)); 
	int x = array_nums[0];
	array_nums[0] = array_nums[array_nums.length-1];
	array_nums[array_nums.length-1] = x;
	System.out.println("New array after swaping the first and last elements: "+Arrays.toString(array_nums));  
 }
}
ArrayMethods.main(null);
Original Array: [20, 30, 40]
New array after swaping the first and last elements: [40, 30, 20]

Check for Duplicates

import java.util.Arrays; 
public class Duplicates {
  public static void main(String[] args) 
    {
        int[] my_array = {1, 2, 5, 5, 6, 6, 7, 2};
 
        for (int i = 0; i < my_array.length-1; i++)
        {
            for (int j = i+1; j < my_array.length; j++)
            {
                if ((my_array[i] == my_array[j]) && (i != j))
                {
                    System.out.println("Duplicate Element : "+my_array[j]);
                }
            }
        }
    }    
}
Duplicates.main(null);
Duplicate Element : 2
Duplicate Element : 5
Duplicate Element : 6

Check if Array is Increasing/Decreasing

import java.math.*;
 
class GFG
{
 
    public static void checkType(int arr[], int n)
    {
     
        if (arr[0] <= arr[1] &&
            arr[n - 2] <= arr[n - 1])
            System.out.println("Increasing");
     
        else if (arr[0] >= arr[1] &&
                 arr[n - 2] >= arr[n - 1])
            System.out.println("Decreasing");
     
        else if (arr[0] <= arr[1] &&
                 arr[n - 2] >= arr[n - 1])
            System.out.println("Increasing then decreasing");
 
        else
            System.out.println("Decreasing then increasing");
    }
         

    public static void main(String[] args)
    {
        int[] arr = new int[]{ 1, 2, 3, 4 };
         
        int n = arr.length;
 
        checkType(arr, n);
    }
}
GFG.main(null);
Increasing