zoukankan      html  css  js  c++  java
  • 关于 "static" 关键字的那点事

     方法的调用的两种方法



         * 1.对象调用 如:对象.方法()

         * 2.类的调用 方法所在类的名字.方法(实参) 前提:这个被调用的方法必须使用static修饰

         * 3.static 是所有对象共享的
         * 4.static 主要用于工具类和功能时

         * 5 没有使用static修饰的方法或字段,属于对象---》实例成员
         * 6.使用static 修饰的方法或字段,属于类  ---》》类成员


    /**
     * Created by Administrator on 2014-10-26.
     */
    public class infoClass {
        private int a;
        private int b;
        private int c;
    
        infoClass() {
        }
    
        ;
    
        public infoClass(int a, int b, int c) {
    
        }
        //static 随着类的加载加载
        //优先于对象存在
    
        /**
         * 方法的调用
         * 1.对象调用 如:对象.方法()
         * 2.类的调用 方法所在类的名字.方法(实参) 前提:这个被调用的方法必须使用static修饰
         * static 是所有对象共享的
         * static 主要用于工具类和功能时
         *
         */
        public class Cellphone {
            void showInfo() {
                infoClass infoClass = new infoClass();
    
            }
    
            /**
             * 没有使用static修饰的方法或字段,属于对象---》实例成员
             * 使用static 修饰的方法或字段,属于类  ---》》类成员
             */
            class Person{
                String Name;
                int aga;
                public   void main(){
                    System.out.println();
                }
            }
        }
    
    }
    


    版权声明:本文为博主原创文章,未经博主允许不得转载。(转载请注明出自 AllenCoder)

  • 相关阅读:
    geowebcache发布 arcgis 瓦片
    BLANK
    基于 SpringBoot 高仿某度网盘项目,前后端分离(含源码)
    基于SpringBoot+WebMagic实现一个的爬虫框架
    博客园主题
    vue el 自动计算时间加1天
    python报警告qt.gtimg.cn
    量化交易日志
    mybatis 一对多。对多对
    DBeaver执行SQL脚本,导入导出
  • 原文地址:https://www.cnblogs.com/allencoder/p/4830756.html
Copyright © 2011-2022 走看看