运算符
与
< &&: 逻辑运算,A&&B,如果A为真,B不会验证,
&:位运算,两边都要运算
数组
一维数组
冒泡排序:
int [] m = {2,10,3,4,1};
for (int i = 0 ; i < m.length;i ++){ //排序的次数
//两两比较,实现排序
for (int j = 0;j < m.length-1;j ++){
if (m[j] > m[j+1]){
int temp = m[j];
m[j] = m[j+1];
m[j+1] = temp;
}
}
}
for (int i = 0; i<m.length;i++){
System.out.println(m[i]);
}
二维数组
输出数组代码:
for (int row = 0;row < arr.length;row ++){
for (int col = 0;col <=row;col++){
System.out.println(arr[row][col]);
System.out.println(' ');
}
System.out.println();
}