zoukankan      html  css  js  c++  java
  • Java中的Static

    1、Static是静态的意思,如果main函数是static类型的,则新写一个类的时候,成员函数或者成员变量如果不是static类型的,则不能通过“类名+.”的方式直接调用,必须通过手动new一个对象,通过"对象+."的方式来访问

    2、写了一个不带static的类(即动态类),在main函数中给这个类new的时候时候,提示:“No enclosing instance of type dm1 is accessible. Must qualify the allocation with an enclosing instance of type dm1 (e.g. x.new A() where x is an instance of dm1).”,

    这是因为新写的类是一个动态的内部类,创建这样的对象必须有实例与之对应,程序是在静态方法中直接调用动态内部类会报这样错误。   这样的错误好比类中的静态方法不能直接调用动态方法。可以把该内部类声明为static。或者不要在静态方法中调用

  • 相关阅读:
    mac安装go环境
    Ubuntu-Mininet安装
    安装pyenv
    linux下安装weblogic
    C#常用方法
    jenkins部署net core ——2
    jenkins部署net core ——1
    Inno Steup
    安装两个SQL server 实例
    C#线程启动、暂停、恢复、停止怎么实现
  • 原文地址:https://www.cnblogs.com/OSKnown/p/8669757.html
Copyright © 2011-2022 走看看