# Maximum of four numbers

• 4
• Locked
Finding the maximum is an n-ary operation (an operation on n numbers) that returns the largest of several numbers. Never mind. We have no need for such definitions at the secret CodeGym center. We're here to learn how to write code. In this task, you need to use the keyboard to enter four numbers. Then determine the largest of them and display it on the screen.
You can't complete this task, because you're not signed in.
BN CRISTIAN
Level 4 , celaya, Mexico
19 February, 22:48
don't use another variable to store the max, just use conditionals and display it
gabrielgcb Backend Developer
4 October 2022, 15:07
My solution, very simple: int max; max = a > b ? a : b; max = max > c ? max : c; max = max > d ? max : d;
Anonymous #10771395 Backend Developer
13 August 2021, 06:52
why this solution is considered wrong? I've tried it several times and everything seems fine.
John Squirrels Website Admin at CodeGym
14 August 2021, 10:56
Please use the Help option within the task menu, if you are having issues with verification.
Jomar Tayactac
Level 2 , Winnipeg, Canada
Expert
1 August 2021, 00:18
I used Arrays.sort() to get the max number.
Anonymous #10775689
Level 14 , United Kingdom
26 July 2021, 15:52
coffeemess
Level 8 , Versailles, France
21 June 2021, 19:50
used arrays.sort :)
schipplock Backend Developer at n/a
4 July 2021, 18:03
lol :)
Seth Barker
Level 5 , Eureka Springs, United States
26 January 2021, 20:27
The topic of Level 4 Lesson 6 should give some insight as to how to correct your code. It was so simple once I realized the most important word. "Equal to"
Khongpak Phupkdee
Level 15 , Chiangrai, Thailand
23 January 2021, 14:23
Thank the community help, because I forgot the negative value. If your result from your code It will be ok but you can't pass in Requirements 3 and 4. Try to change your input data from 8,9,5,8 to -8,-9,-5,-8, and check your result again! Good luck
Ryan Palmer
Level 20 , Philadelphia, United States
16 January 2021, 04:43
When using Intellij how do you input your own numbers? When I attempt to use "Run" and then type in the console I can only enter 1 number. When I push enter I receive the following message. xception in thread "main" java.lang.NumberFormatException: For input string: "1 " at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68) at java.base/java.lang.Integer.parseInt(Integer.java:652) at java.base/java.lang.Integer.parseInt(Integer.java:770) at com.codegym.task.task04.task0419.Solution.main(Solution.java:13)
Alex Vypirailenko Java Developer at Toshiba Global Comme
16 January 2021, 17:10