对IndexOutOfBoundsException的引用是不明确的

sen*_*ale 0 java

错误:

对IndexOutOfBoundsException的引用是不明确的,com.sun.star.lang中的类com.sun.star.lang.IndexOutOfBoundsException和java.lang中的类java.lang.IndexOutOfBoundsException匹配

码:

public void insertIntoCell(int CellX, int CellY, String theValue, 
                             XSpreadsheet TT1, 
                             String flag) throws IndexOutOfBoundsException {

    XCell oCell = null;
    oCell = TT1.getCellByPosition(CellX, CellY);

    if (flag.equals("V")) {
      oCell.setValue((new Float(theValue)).floatValue());
    } else {
      if (theValue!=null && theValue.length()>0 && theValue.length()!=0) { 
          oCell.setFormula("'"+(String)theValue.toString());
      } else {
          oCell.setFormula((String)theValue.toString());
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

pol*_*nts 5

完全限定异常类型.

public void insertIntoCell.. throws com.sun.star.lang.IndexOutOfBoundsException {
}
Run Code Online (Sandbox Code Playgroud)

我在这里假设你不打算扔java.lang.IndexOutOfBoundsException,这是一个不受控制的RuntimeException,但我可能是错的.

您也可以使用单一类型的导入声明:

import com.sun.star.lang.IndexOutOfBoundsException;
//...

public void insertIntoCell.... throws IndexOutOfBoundsException {
}
Run Code Online (Sandbox Code Playgroud)

但这可能会导致管道混乱.