程序如下:
class DrumKit
{
boolean topHat = true;
boolean snare = true;
void playTopHat()
{
System.out.println("ding ding da-ding");
}
void playSnare()
{
System.out.println("bang bang ba-bang");
}
public static void main(Sring[] args)
{
DrumKit d = new DrumKit();
d.playSnare();
d.snare = false;
d.playTopHat();
if (d.snare == true)
{
d.playTopHat();
}
}
}
保存时提示:Sring cannot be resolved to a type
运行不了,是用eclipse写的
------解决方案--------------------------------------------------------
main方法中应该是main(String[] args) 而不是main(Sring[] args) 。且if (d.snare == true)
最好写成if (d.snare)即可了。希望对你有帮助!