Calling a Method Define a Static method 'max' with return type as 'int' in class 'ProblemSolution' that take two numbers with type 'int'. Inside the 'max' method, compare the two numbers and return the maximum of the two numbers. Then, inside the 'main' method. Define two 'int' type numbers; the first number (num1) is equal to 5 and the second number (num2) is equal to 2. At the next line, call the 'max' method where its parameter input are the two numbers above, and assign the result of the method to the variable num3 (type 'int'). Finally, on the next line, print out -> "The maximum of " + num1 + " and " + num2 + " is " + num3 Output The maximum of 5 and 2 is 5 Where, There must be space between all the words and numbers. There should not any space after the last number.
Define a Static method 'max' with return type as 'int' in class 'ProblemSolution' that take two numbers with type 'int'. Inside the 'max' method, compare the two numbers and return the maximum of the two numbers.
Then, inside the 'main' method.
Define two 'int' type numbers; the first number (num1) is equal to 5 and the second number (num2) is equal to 2.
At the next line, call the 'max' method where its parameter input are the two numbers above, and assign the result of the method to the variable num3 (type 'int').
Finally, on the next line, print out -> "The maximum of " + num1 + " and " + num2 + " is " + num3
Output
The maximum of 5 and 2 is 5
Where,
There must be space between all the words and numbers.
There should not any space after the last number
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images