sys*_*bug 5 java netbeans class
我已经定义了具有多种方法的A类.然后我有另一个类,即JSF的托管bean.在bean中我创建了一个A类实例,但后来我无法调用A类中的任何方法.所有字段都是公共的,方法范围也是公共的.
我认为这可能是因为bean的性质(虽然它不应该)所以我创建了另一个类Tester.java并创建了实例,并且没问题.但是当我尝试调用这些方法时,Netbeans中的建议列表中没有显示任何内容.到底是怎么回事?谢谢,
编辑:代码:
public class Reservation {
.... //setters & getters
public List<DateTime> getDateRange(DateTime start, DateTime end) {
......//body of method
}
public TreeMap<DateTime, Integer> getDatesTreeMap(){
//body of method
}
public boolean checkRange() {
... body of method
}
}//end of class - no errors
Run Code Online (Sandbox Code Playgroud)
然后这就是类实例化的方式:
Reservation booking = new Reservation();
booking. ????? this is where the suggestions don't come up
Run Code Online (Sandbox Code Playgroud)
谢谢
一个猜测(因为你仍然没有显示足够的代码来确定,但......)
您可能尝试在类中以及方法或构造函数块之外调用方法.换句话说,这段代码:
Reservation booking = new Reservation();
booking. ????? this is where the suggestions don't come up
Run Code Online (Sandbox Code Playgroud)
可能在类的声明部分中调用,但不在方法块,构造函数块或其他类似构造内部调用.这里只能调用变量声明及其相关的初始化代码,但其他语句(如调用变量方法)则不能.
解决方案:在方法或构造函数块中调用它所属的代码.
| 归档时间: |
|
| 查看次数: |
6341 次 |
| 最近记录: |