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。或者不要在静态方法中调用

  • 相关阅读:
    CentOS/RHEL 查看用户登陆信息
    PAM
    块存储
    ECS
    SQL 基础应用
    MySQL 基础管理
    MySQL 体系结构
    JSON对象
    设置dom节点属性的代码优化
    Ext框架下的元素拖动
  • 原文地址:https://www.cnblogs.com/OSKnown/p/8669757.html
Copyright © 2011-2022 走看看