基本上我希望这个代码只在项目textBooks在库存中时执行,现在它始终执行。我不知道在if语句中放什么,因为我所做的只是使currentMessage等于它之前的值。
public void read(){
boolean found = myArray.contains("textBooks");
currentMessage = "sorry you cannot read this text book because you are not the all knowing";
}
答案 0 :(得分:1)
if(myArray.contains("textbooks"))
currentMessage = "You may read"
else
currentMessage = "You may not read"
我还建议你看一下这里的java基础知识http://docs.oracle.com/javase/tutorial/java/nutsandbolts/