Udemy REST Assured free

Given an array of ints, return true if 6 appears as either the first or last element in the array. The array will be length 1 or more.

Check Below Code:

package com.test.arrays;

public class SixFirstLast 
{
	public static void main(String args[])
	{
		SixFirstLast sf = new SixFirstLast();
		System.out.println(sf.firstLast6(new int[] {1, 2, 6}));
		System.out.println(sf.firstLast6(new int[] {2, 4, 6, 8}));
		System.out.println(sf.firstLast6(new int[] {6, 4, 6, 6}));
	}

	public boolean firstLast6(int[] nums) 
	{
		if(nums[0]==6 || nums[nums.length-1] == 6)
			return true;
		else
			return false;
	}
}	

Output

true
false
true