-2
例如,我想我的。然而IDE(我使用Eclipse)说:“食物不能被解析为一个变量”写类似是否有关键字允许我创建一个带有文本值的变量?
class TestingStuf {
public static void main(String[] args) {
int bleh;
bleh = food;
System.out.print("I am trying to");
System.out.println(" write some code.");
System.out.print(bleh);
System.out.println("help me please.");
}
}
。我认为这是因为关键字“int”不适用于像“食物”这样的实际短语。那么是否有一个关键字可以让我写这个,或者是否有其他解决方案可以工作?任何帮助赞赏。谢谢。
你必须首先引入'食物'变量:'int bleh,food;' – DimaSan
'int food = -99;'然后'bleh =食物;'会起作用。 –
'int'是变量的_type_,表示一个整数。如果你想存储_text_,你需要一个'String',例如'字符串bleh =“食物”;'。 –