The code box below includes a live int array variable called nums, whose declaration and initialization is hidden. The elements in this array are distinct. What is the largest element in the array? Write appropriate code, involving a loop, that will print this value to the console.
The answer you enter should execute exactly one System.out.println statement.
And below is my code:
int largest = nums[0];
for (int j = 0; j < nums.length; j++){
largest = nums[j];
System.out.println(largest);
}
it doesn't come out with the largest element. I don't know why. Can anyone help?