2010-11-16 83 views
1

下面是我的代碼爲明星的構造,我傳遞了正確的價值觀,但我不斷收到一個找不到符號錯誤明星構造找不到方法的錯誤

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; 
} 

感謝俺們傢伙..關於放棄......

回答

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

調用構造函數與new關鍵字,而不是與Class.Class(...)

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

1

而不是

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

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

Star方法ISN」 t一個公共靜態類,所以你不能做Star.Star(如果可能的話)。