public static class Binary extends Formula {
      
      public Binary(TptpParserOutput.FofFormula lhs,
                    TptpParserOutput.BinaryConnective connective,
                    TptpParserOutput.FofFormula rhs)
      {
        _kind = Formula.Kind.Binary;
        _lhs = (Formula)lhs;
        _connective = connective;
        _rhs = (Formula)rhs;
      }
      
      
      
      public TptpParserOutput.BinaryConnective getConnective() {
        return _connective;
      }
      
      public  Formula getLhs() { return _lhs; }
      
      public Formula getRhs() { return _rhs; }
      
  
      
      /** @param obj must be convertible to Binary, can be null */
      public boolean equals(Object obj) {
        if (obj == null) return false;
        if (this == obj) return true;
        return _kind == ((Formula)obj)._kind && 
        _connective == ((Binary)obj)._connective &&
        _lhs.equals(((Binary)obj)._lhs) &&
        _rhs.equals(((Binary)obj)._rhs);
      }
      
      public int hashCode() {
        int res = _kind.hashCode();
        res = 31 * res + _connective.hashCode();
        res = 31 * res + _lhs.hashCode();
        res = 31 * res + _rhs.hashCode();
        return res;
      }
      
      
      public String toString() { return toString(new String("")); }
      
      public String toString(String indent) {
        return indent + "(" + _lhs + _connective + _rhs + ")";
      }
      
      
      
      public Formula _lhs;
      public TptpParserOutput.BinaryConnective _connective;
      public Formula _rhs;
    } // class Binary这是一个静态类,如果我想在其他类中访问这两个方法,该如何做?    public  Formula getLhs() { return _lhs; }
      
public Formula getRhs() { return _rhs; }

解决方案 »

  1.   

    静态类应该是某个类的内部类,
    假设你的Binary所在的外部类名称为A,
    那么应该这样访问: new A.Binary().getLhs();
    因为你这两个方法不是静态的,所以应该是 new 一下。
    如果方法用static修饰,则直接A.Binary.getLhs();
    希望能帮助你。
      

  2.   

    你那两个方法又没有申明static,只能生成Binary的对象,然后通过该对象调用。另外,你的代码好像有些问题,因为static类只有在内隐的时候才有意义。
      

  3.   

    你的静态类  没有static  应该先new一下
      

  4.   


    没有static关键字修饰的类,能算是静态类吗?不太懂了
      

  5.   

    5楼的意思是楼主的方法没有static修饰,所以静态类要new一下。
      

  6.   


    此类就是静态内部类,因为代码太多,所以只贴了静态类.
    那个java文件,只有第一个是普通类,里面都是潜逃的静态内部类。
    如果我想访问,里面的
    getLhs()
    getRhs()
    方法,2楼说的可用吗?
    代码没问题。
      

  7.   

    普通类.静态类 静态类对象 = new 普通类.静态类();
    静态类对象.普通方法();
      

  8.   

    二楼说的是对的。另外,要调用非static方法,你必须先生成对象,比如在那个普通类(也就是Binary的外部类)的内部,可以直接用Binary b = new Binary(lhs, rhs);来生成对象b,然后用b.getLhs()来调用方法。郁闷的是,你既然可以生成b的对象,就已经有了lhs和rhs,又何必调用b.getLhs()和b.getRhs()呢?
      

  9.   

    最后两个public Lhs和public Rsh是我自己添加的。
    原来是private或者是protected.
    我忘了。