zoukankan      html  css  js  c++  java
  • flutter--static关键字

    class Page {
      int currentPage = 1;
    
      static void scorllDown() {
        ///错误:static方法不能访问普通成员变量
        currentPage = 1;
        print("ScrollDown...");
      }
    
      void scorllUp() {
        currentPage ++;
        print("ScrollUp...");
      }
    }
    class Page {
      // 添加 static 关键字
      static int currentPage = 1;
    
      static void scorllDown() {
        currentPage = 1;
        print("ScrollDown...");
      }
    
      void scorllUp() {   ///普通成员方法可以访问static成员变量
        currentPage ++;
        print("ScrollUp...");
      }
    }

    static方法和成员方法的调用区别:

    Page类:

    class Page {
      // 添加 static 关键字
      static int currentPage = 1;
    
      static void scorllDown() {
        currentPage = 1;
        print("ScrollDown...");
      }
    
      void scorllUp() {   ///普通成员方法可以访问static成员变量
        currentPage ++;
        print("ScrollUp...");
      }
    }

     

  • 相关阅读:
    swoole 查看tcp开启进程数
    详解LRU缓存算法
    glib 双向链表
    清华计算机本科 课表
    glib 单向链表
    通信课程
    基数排序
    glib 数组
    glib 散列表
    清华计算机博士 课表
  • 原文地址:https://www.cnblogs.com/FdWzy/p/13619754.html
Copyright © 2011-2022 走看看