java 基础语法 (和PHP对比)

1: 常量 Java finanal  PHP const

2     数据的定义:

       声明数组  数据类型[ ] 数组名   或者   数据类型 数组名[ ];

         int[] scores ;或者 int scores[];

       分配空间   数组名 = new  数据类型 [ 数组长度 ];

          scores= new int[5]

         我们也可以将上面的两个步骤合并,在声明数组的同时为它分配空间,如:

          int scores[] = new int(5);

          注意:分配空间后才能赋值

         scores[0] = 100;

        在 Java 中还提供了另外一种直接创建数组的方式,它将声明数组、分配空间和赋值合并完成,如:

扫描二维码关注公众号,回复: 2223445 查看本文章

        int scores[]={78,91,84,68} 或者 int scores= new int[]{78,91,84,68}

猜你喜欢

转载自blog.csdn.net/fish_study_csdn/article/details/81094862