Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

LANGUAGE: JAVA

CHALLENGE:
Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

SOLUTION:

if ( x > y)
    max = x;
else
    max = y;

Add comment