学习内容:
今天跟着老师,一起把前两天讲的关于“运算符”、“流程控制”、“数组结构”、和“面向对象”里面的内容进行了一个加深和回顾。
部分代码:
package com.doke;
public class Client3 {
public static void main(String[] args) {
int flag = 6;
int sum = 0;
for (int i = 1; i <= 10; i++) {
if (i == flag) {
break;
}
sum = sum + i;
}
System.out.println(sum); // 1+2+3+4+5+6
}
}
运行结果为“15”。
package com.doke;
public class Client4 {
public static void main(String[] args) {
String[] strs = {"a", "b", "c"};
String[] strs2 = new String[]{"a", "b", "c"};
String[] strs3 = new String[3];
String[] follows = {"♦","♣","♥","♠"};
String[] points = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
String[] pokers = new String[52];
int pokerIndex = 0;
for (int i = 0; i < points.length; i++) {
for (int j = 0; j < follows.length; j++) {
pokers[pokerIndex++] = points[i] + follows[j];
}
}
for (String poker : pokers) {
System.out.print(poker + " ");
}
}
}
运行结果为“2♦ 2♣ 2♥ 2♠ 3♦ 3♣ 3♥ 3♠ 4♦ 4♣ 4♥ 4♠ 5♦ 5♣ 5♥ 5♠ 6♦ 6♣ 6♥ 6♠ 7♦ 7♣ 7♥ 7♠ 8♦ 8♣ 8♥ 8♠ 9♦ 9♣ 9♥ 9♠ 10♦ 10♣ 10♥ 10♠ J♦ J♣ J♥ J♠ Q♦ Q♣ Q♥ Q♠ K♦ K♣ K♥ K♠ A♦ A♣ A♥ A♠ ”