Cannot Find method error
Below is my code for the Star constructor, i'm passing the correct values but i keep getting a cannot find symbol error for the star constructor
private Star[] star;
st = db.readLineFromDB();
ST = new StringTokenizer(st , ",");
star[count] = Star.Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integ开发者_JAVA百科er.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;
}
Thanks guys for the ans... about to give up...
star[count] = new Star(...);
You invoke constructors with the new
keyword, not with Class.Class(...)
.
Instead of
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());
The Star
method isn't a public static class so you can't do Star.Star
(if that's possible).
Star.Star(Double.valueOf(ST.nextToken()),Double.valueOf(ST.nextToken()),ST.nextToken(),Integer.valueOf(ST.nextToken()),ST.nextToken());
This is not the way to call constructor.
you should do some thing
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
精彩评论