Java基础 关于数组复制,switch

总结:数组复制:用指针指的,万物皆对象
switch三观尽毁…
ASCALL码:https://blog.csdn.net/u011930916/article/details/79623922

run结果:

在这里插入图片描述

package com.company;

public class Main {

    public static void main(String[] args) {
	// write your code here
        char c = '\0';
        for(int i = 1; i <=4; ++i)
        {
            System.out.println( "\n" + i);
            switch (i)
            {
                case 1: c = 'J';
                    System.out.print(c);
                case 2: c = 'e';
                    System.out.print(c);
                    break;
                case 3: c = 'p';
                    System.out.print(c);
                default: System.out.print("好");
            }
        }
    }
}

在这里插入图片描述

package com.company;

public class Main {

    public static void main(String[] args) {
	// write your code here
        int [] a={10,20,30,40}, b[]={ {1,2}, {4,5,6,7} };
        b[0] = a;
        b[0][1] = b[1][3];

        for(int i = 0; i <a.length; ++i)
        {
            System.out.println( ">>" + a[i] + "<<");
        }


        System.out.println(b[0][3]);
        System.out.println(a[1]);
    }
}


循环代码执行顺序:

在这里插入图片描述

package com.company;

public class Main {

    public static void main(String[] args) {
        int x = 1;
        int y = 6;

        while (y-- > 0) {
            System.out.println(x + " >> " + y);
            x--;
        }

        System.out.println(x + " ------ " + y);
    }
}

发布了84 篇原创文章 · 获赞 9 · 访问量 9170

猜你喜欢

转载自blog.csdn.net/qq_42344456/article/details/102944183