Foreword:
Sort out some sample questions in java.
Online compilation: entry
System.out.println and System.out.print of java Personal online test code tool sharing: Entry Personal understanding: System.out.println() == The front-end console.log is the specific meaning of the print content: System is a class, and out is a static constant of the PrintStream type under the System class; . .. https://blog.csdn.net/qq_41619796/article/details/123066958
Realize the effect:
The output of the following program segment is:
public class TestArray {
public static void main(String[] args) {
int i,j;
int a[] = {5,9,6,8,7};
for(i=0;i<a.length-1;i++){
int k = i;
for(j=i;j<a.length;j++){
if(a[j]>a[k]) k=j;
int temp = a[i];
a[i] = a[k];
a[k] = temp;
}
for(i=0;i<a.length;i++){
System.out.print(a[i]+" ");
System.out.println();
}
}
}
}
Output result:
7
5
6
8
9