集册 Java实例教程 声明许多具有不同访问级别的班级成员:

声明许多具有不同访问级别的班级成员:

欢马劈雪     最近更新时间:2020-01-02 10:19:05

529
声明许多具有不同访问级别的班级成员:
/* 
 来自 
*n  o  w  j  a  v  a . c o m*/

public class Main { 

        private int num1;   // private access level 

        int num2;           // package-level access 

        protected int num3; // protected access level 

        public int num4;    // public access level 

  

        public static int count = 1; // public access level 

  

        // m1() method has private access level 

        private void m1() { 

        } 

  

        // m2() method has package-level access 

        void m2() { 

        } 

  /*来自 n o w j a   v  a . c o m - 时  代  Java*/

        // m3() method has protected access level 

        protected void m3() { 

        } 

  

        // m4() method has public access level 

        
展开阅读全文