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(); } }
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]);
}
}
}
+ 9
Try using an array
https://code.sololearn.com/cifooObACjl1/?ref=app
+ 9
Not using array.sort, it requires importing libraries. try the bubble sort method.
https://www.sololearn.com/learn/649/?ref=app
+ 6
Hi Icefield
The code is missing
+ 1
Thank you so much for reminding.
+ 1
Can I have a java version of that? jay
0
Thank you!
0
I see, can we do that without importing anything?