我写了一个单例类来跟踪我的应用程序中的一些变量。
我收到一个我无法弄清楚的语法错误,我确信我错过了一些简单但却是其中一天的错误。有人看到我的代码出了问题吗?
错误是1084:语法错误:在resultNumber之前期待rightparen。
public static function setResult(int resultNumber, int value): void
{
switch(resultNumber)
{
case 2: { this.result2 = value; break; }
case 3: { this.result3 = value; break; }
case 4: { this.result4 = value; break; }
case 5: { this.result5 = value; break; }
case 6: { this.result6 = value; break; }
case 7: { this.result7 = value; break; }
case 8: { this.result8 = value; break; }
case 9: { this.result9 = value; break; }
case 10: { this.result10 = value; break; }
case 11: { this.result11 = value; break; }
case 12: { this.result12 = value; break; }
case 13: { this.result13 = value; break; }
case 14: { this.result14 = value; break; }
}
}
答案 0 :(得分:5)
这不是Java:
public static function setResult(resultNumber:int, value:int): void
{
switch(resultNumber)
{
case 2: { this.result2 = value; break; }
case 3: { this.result3 = value; break; }
case 4: { this.result4 = value; break; }
case 5: { this.result5 = value; break; }
case 6: { this.result6 = value; break; }
case 7: { this.result7 = value; break; }
case 8: { this.result8 = value; break; }
case 9: { this.result9 = value; break; }
case 10: { this.result10 = value; break; }
case 11: { this.result11 = value; break; }
case 12: { this.result12 = value; break; }
case 13: { this.result13 = value; break; }
case 14: { this.result14 = value; break; }
}
}