无法查找方法错误

时间:2010-11-16 09:25:30

标签: java methods find

下面是我的Star构造函数的代码,我正在传递正确的值,但我一直找不到星形构造函数的符号错误

private Star[] star;
st = db.readLineFromDB();
ST = new StringTokenizer(st , ",");
star[count] = Star.Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());
count++;

public Star(double logdist, double vmag, String sp_class, int ID, String name)
 {
 this.logdist = logdist;
 this.vmag = vmag;
 this.sp_class = sp_class;
 this.ID = ID;
 this.name = name;
 }

谢谢你们的回答...即将放弃......

3 个答案:

答案 0 :(得分:1)

star[count] = new Star(...);

您使用new关键字调用构造函数,而不是Class.Class(...)

答案 1 :(得分:1)

Star.Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());

这不是调用构造函数的方法。

你应该做点什么

Star starObj = new Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());

Have a detail look at this tutorial

答案 2 :(得分:1)

而不是

star[count] = Star.Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());

DO

star[count] = new Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());

Star方法不是公共静态类,因此您无法Star.Star(如果可能的话)。