我正在尝试从以下类中实例化一个对象:
public class Name {
//The unmodified name
private String name;
//The modified name
private String preprocessedName;
/**
* Constructor method which stores the original name in the name variable
* @param inputName
*/
public Name(String inputName){
//Store the name
this.name = inputName;
//Initialise the preProcessedName
this.preprocessedName = null;
}
/**
* Retrieves the original name
* @return the original name
*/
public String getName(){
return this.name;
}
/**
* Stores the preprocessed name in the preprocessedName variable
* @param the preprocessed name
*/
public void setPreprocessedName(String processedInput){
this.preprocessedName = processedInput;
}
/**
* Retrieves the preprocessed name
* @return the preprocessed name
*/
public String getpreprocessedName(){
return this.preprocessedName;
}
}
在以下方法中:
/**
* Private method which instantiates names as a name object.
* @param names
*/
private void processInput(ArrayList<String> names){
library = new ArrayList<Name>();
for(String name : names){
Name tempName = new Name("r");
//Not bringing up any methods from the class
**strong text**tempName.**strong text**
//add to the library
library.add(tempName);
}
}
创建对象时,我无法使用Name类中的任何方法,你知道为什么会这样吗?例如当我尝试自动完成时,它不会从课堂上调出getter和setter。
答案 0 :(得分:0)
检查包中的导入。 您是否导入了正确的Name类?