about | help | code help+videos | done | prefs |
public int getLargest2(int[] nums)
public int getLargest2(int[] nums) { int largest = nums[0]; if (nums[1] > largest) { largest = nums[1]; } return largest; }Note: Another way to check for the larger of two values is to use Math.max(): public int getLargest2(int[] nums) { int largest = Math.max( nums[0], nums[1] ); return largest; } getLargest2([5, 10]) → 10 getLargest2([10, 5]) → 10 getLargest2([3, 6]) → 6 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 1
Copyright Nick Parlante 2017 - privacy