渡课学习 2018.8.24

学习内容:

今天跟着老师,一起把前两天讲的关于“运算符”、“流程控制”、“数组结构”、和“面向对象”里面的内容进行了一个加深和回顾。


部分代码:

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♠ ”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值