Udemy REST Assured free

Given an array of ints, return true if the array is length 1 or more, and the first element and the last element are equal.

Check below code:

package com.test.arrays;

public class FirstLastEqual 
{
	public static void main(String args[])
	{
		FirstLastEqual fl = new FirstLastEqual();
		System.out.println(fl.sameFirstLast(new int[] {1, 2, 1}));
		System.out.println(fl.sameFirstLast(new int[] {1, 2, 3, 1}));
		System.out.println(fl.sameFirstLast(new int[] {1, 2, 3}));
	}
	
	public boolean sameFirstLast(int[] nums) 
	{
		if(nums.length >= 1 && nums[0] == nums[nums.length-1])
			return true;
		else
			return false;	  
	}
}

Output

true
true
false