jadexu07
import org.junit.Test;

public class Demo {
    @Test
    public void test1(){
        /*
        关于数组输出的测试
        char[]直接输出时,各字符会拼接成字符串输出。
        char[]拼接字符串后再输出,则输出数组的地址值。
        引用数据类型输出类名+地址值
        其余基本数据类型输出地址值
        综上所述,char[]需要特别注意下
         */
        char c[] = {\'c\',\'h\',\'i\',\'n\',\'a\'};
        Character ch[] = {\'c\',\'h\',\'i\',\'n\',\'a\'};
        String s[] = {"ch","ina"};
        Demo demo[] = {};
        int i[] = {1,2,3};
        double d[] = {2.2,3.3};
        boolean bool[] = {true,false};

        System.out.println("char数组输出:");
        System.out.print("直接输出:");
        System.out.print(c);
        System.out.print("\n拼接字符串输出:");
        System.out.print("char[] = "+c+"\n");

        System.out.println("************************************************************");

        System.out.println("引用数据类型数组输出:");

        System.out.println("直接输出:");
        System.out.println(ch);
        System.out.println(s);
        System.out.println(demo);
        
        System.out.println("拼接字符串输出:");
        System.out.println("Character[]:"+ch);
        System.out.println("String[]:"+s);
        System.out.println("Demo[]:"+demo);

        System.out.println("************************************************************");

        System.out.println("其它基本数据类型数组输出:");

        System.out.println("直接输出:");
        System.out.println(i);
        System.out.println(d);
        System.out.println(bool);

        System.out.println("拼接字符串输出:");
        System.out.println("int[]:"+i);
        System.out.println("double[]:"+d);
        System.out.println("boolean[]:"+bool);
    }
}

 

分类:

技术点:

相关文章:

  • 2021-12-26
  • 2022-01-12
  • 2021-12-17
  • 2021-07-19
  • 2021-05-07
  • 2021-07-19
  • 2021-06-12
猜你喜欢
  • 2021-11-06
  • 2022-02-23
  • 2021-12-19
  • 2022-02-08
  • 2021-11-16
  • 2021-11-14
  • 2021-05-26
相关资源
相似解决方案