1. Printing
print--printing, no line break, add line breaks as required
println--Print once and wrap it up.
printf--printing, inherit C speech format, can be formatted output
Line break
' \ R ' is a carriage return, ' \ n ' is a newline, ' \ t ' is a tab
Method of use: 1. SYSTEM.OUT.PRINTLN ("Thank you for your support \ n");
2.SYSTEM.OUT.PRINTLN (i+ "*" +j=i*j+ "\ n");
2. Bubble sort
Used for array sorting, comparing the first and neighboring elements, sequentially comparing the number of adjacent neighbors, and the last one being the maximum number.
If there is n number, then the N-1 cycles;
Each cycle, 22 comparisons, the last element is no longer compared with the previous one.
for (int i=0;i<arr.length-1;i++) {
for (int j=0;j<arr.length-1-i;j++) {
if (Arr[j]>arr[j+1]) {
TEMP=ARR[J];
ARR[J]=ARR[J+1];
Arr[j+1]=temp;
}
}
}
3. Array new
int arr[]=new int[5];
4.Scanner input
Import Scanner Class Package
Sacnner input= New Scanner (system.in);
Arr[i]=input.nextint ();
java-Bubble Sort