0

What is wrong with my code?

I want to sort the numbers by being the biggest. Math.max can only take 2 numbers so I had to do it like this. public class wow { { int a = Math.max(5, 9); int b = Math.max(98, 456); int c = Math.max(625, 321); int d = Math.max(474, 514); int e = Math.max(a, b); int f = Math.max(c, d); int g = Math.max(e, f); int m = Math.max(g, 54); } System.out.println(int m); } public class Program { public static void main(String[] args) { Program hah = new Program(); wow.hah(); } }

19th Jun 2018, 1:45 PM
Icefield
Icefield - avatar
8 Réponses
+ 11
Pretty much the same import java.util.*; public class Program { public static void main(String[] args) { //create array int[] numbers = { 5, 14, 11, 1}; //sort array Arrays.sort(numbers); //display sorted array for(int i=0;i < numbers.length; ++i) { System.out.println(numbers[i]); } } }
19th Jun 2018, 2:31 PM
jay
jay - avatar
19th Jun 2018, 2:15 PM
jay
jay - avatar
+ 9
Not using array.sort, it requires importing libraries. try the bubble sort method. https://www.sololearn.com/learn/649/?ref=app
19th Jun 2018, 2:38 PM
jay
jay - avatar
+ 6
Hi Icefield The code is missing
19th Jun 2018, 1:58 PM
jay
jay - avatar
+ 1
Thank you so much for reminding.
19th Jun 2018, 1:59 PM
Icefield
Icefield - avatar
+ 1
Can I have a java version of that? jay
19th Jun 2018, 2:23 PM
Icefield
Icefield - avatar
0
Thank you!
19th Jun 2018, 2:17 PM
Icefield
Icefield - avatar
0
I see, can we do that without importing anything?
19th Jun 2018, 2:32 PM
Icefield
Icefield - avatar