public class HelloWorld{
public static void main(String[] args){
int[] a = new int[5];
a[0] = (int) (Math.random() * 100);
a[1] = (int) (Math.random() * 100);
a[2] = (int) (Math.random() * 100);
a[3] = (int) (Math.random() * 100);
a[4] = (int) (Math.random() * 100);
System.out.println("The individual random numbers in the array are :");
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
System.out.println("bubble sorting method: (compare two by two, put the bigger one behind)");
for (int j = 0; j < a.length; j++) {
for (int i = 0; i < a.length-j-1; i++) {
if(a[i]>a[i+1]){
int temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
}
}
}
System.out.println("the minimum number is"+a[0]);
}
}
Read More:
- JAVA: Random access file is always garbled
- Abstract method and static method of java interface
- JAVA: How to use the third-party font library method (using the third-party TTF / TTC font library method)
- Asynchronous processing of HTTP request by Java_ Method 2: through deferredresult
- How to Fix Error Caused by: java.util.MissingResourceException: Can‘t find bundle for base name xxx, locale zh_CN
- Asynchronous processing of HTTP request by Java_ Method 1: through callable
- Java uses class array to report error Exception in thread “main” java.lang.NullPointerException solution
- How to convert a Java string into a number (stringtonumber)
- Caused by: java.lang.IllegalStateException (How to Fix)
- JAVE: LeetCode(189) Rotate Array
- Java: How to use itext to export PDF text absolute positioning (implementation method)
- Java error: unable to find or load main class (package name in source file)
- JAVA 8: How to Convert List to Map
- [Solved] Method threw ‘java.lang.StackOverflowError‘ exception. Cannot evaluate
- JAVA: How to Delete the Last Bit of String
- How to Open Files by Dragging and Dropping in C#
- JAVA: How to Read JSON Format Data (Web Game Development)
- How to Close the Current Form in JAVA Swing
- Java Running Error: Could not find or load main class
- JAVA: How to Convert PDF from Color to Grayscale