zoukankan      html  css  js  c++  java
  • java——关于数组的定义 和 访问修饰符的修饰内容

    public class Shuzu {
    
        public static void main(String[] args) {
    
            // 定义数组 必须初始化长度,没有初始化要放数据
    
            int[] in = { 1, 2, 3, 4, 5, 6 }; // 第一种方法:直接赋值
            for (int i = 0; i < in.length; i++) {
                System.out.print(in[i] + "	");
            }
            System.out.println();
    
            int[] in1 = new int[3]; // 第二种方法:用new方法,[]里面定义长度
            in1[0] = 1;
            in1[1] = 2;
            in1[2] = 3;
            for (int i = 0; i < in1.length; i++) {
                System.out.print(in1[i] + "	");
            }
            System.out.println();
            
            // 第三种方法:用new方法,[]里面不定义长度,在后面直接赋值
            int[] in2 = new int[] { 1, 2, 3, 4, 5, 6 };
            for (int i = 0; i < in2.length; i++) {
                System.out.print(in2[i] + "	");
            }
            System.out.println();
        }
    
    }

    访问修饰符未定义的话,默认为protected

    修饰符 类内部 同一个包 子类 任何地方
    privated yes      
    default yes yes    
    protected yes yes yes  
    public yes yes yes yes
  • 相关阅读:
    2020.12.15
    2020.12.14
    2020.12.13
    2020.12.11
    2020.12.10
    语音合成标记语言(SSML)
    Skyline查询
    win10 VMware 安装 Linux 虚拟机
    图像梯度计算
    Harris Corner Detection
  • 原文地址:https://www.cnblogs.com/Chenshuai7/p/5060685.html
Copyright © 2011-2022 走看看