/**
*
* Ashish Patel
* e: ashishsushilPatel@gmail.com
* w: https://ashish.me
*
*/
class LargestElement {
static int func(int[] nums) {
int result = 0;
for (int i = 1; i < nums.length; i++) {
if(nums[i] > nums[result]){
result = i;
}
}
return result;
}
public static void main(String args[]) {
int[] nums = {10, 20, 30, 40};
int result = func(nums);
System.out.println(result);
}
}
Created 2021-10-26T03:12:44+01:00, updated 2021-10-26T19:15:26+01:00 · History · Edit