# CodingBat Java Solutions - Array1

Given an array of ints length 3, figure out which is larger between the first and last elements in the array, and set all the other elements to be that value. Return the changed array.
maxEnd3({1, 2, 3}) → {3, 3, 3}
maxEnd3({11, 5, 9}) → {11, 11, 11}
maxEnd3({2, 11, 3}) → {3, 3, 3}

### Solution:

public int[] maxEnd3(int[] nums) {
int max = Math.max(nums, nums);
nums = max;
nums = max;
nums = max;
return nums;

// Solution notes: you could write if-logic to figure out
// which element is the biggest, but here we use Math.max()
// to solve that part nicely.
}

### OR

public int[] maxEnd3(int[] nums) {
int[] maxVal=new int;
maxVal=nums;
if(nums >= maxVal)
maxVal = nums;
maxVal = maxVal;
maxVal = maxVal;
return maxVal;
}

1. Java Training Institutes Java Training Institutes Java EE Training in Chennai Java EE Training in Chennai Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai

Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training

2. 3. 