在我的程序中,用户声明了一串数字,我试图将其转换为数组。
例子:
WeeklyFiber week2 = new WeeklyFiber("CS4567", "11/24/13", 32, "27, 26, 28");
我试图弄清楚如何将该字符串添加到我的类实例变量中。
这就是我所拥有的:
private String sampleID;
private String weekOfTest;
private int engineerID;
private String[] strengths = new String[20];
private static int count;
public WeeklyFiber(String sampleID, String weekOfTest, int engineerID, String strengths)
{
this.sampleID = sampleID;
this.weekOfTest = weekOfTest;
this.engineerID = engineerID;
this.strengths = strengths;
count++;
}
我的编译错误消息说类型不兼容,需要:String[],找到:String