因此,当我编译此程序时,java会给出一条错误消息:解析时到达文件末尾 公共类MohoscopeEngine实现了HoroscopeEngine { ^
//MohoscopeEngine.java
public class MohoscopeEngine implements HoroscopeEngine{
final String[] constant ={"Bring your friends from ", "and ", "to go to party at "};
String[] fiveplaces = {"Rocky", "Safford", "Chapin", "Art Museum", "Mead"};
/** generate random index for array without repeating*/
public String randomIndex(){
int index = (int)(Math.floor(Math.random()*5));
return fiveplaces[index];
}
public String getHoroscope(){
//for(int i =0; i < index.length; i++)
String mohoscope = constant[0] + randomIndex() + constant[1] + randomIndex() + constant[2] + randomIndex();
return mohoscope;
}
}
我不认为我没有附上课程,我检查了每个支架和支架,发现没有错。为什么会出现问题以及我该如何解决?