如果声明带有字符串和&& [英] If statement with strings and &&

查看:100
本文介绍了如果声明带有字符串和&&的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if((word1!= word2)&&(word1!= word3)&&(word 2!= word3)){

outputString = outputString +\ n \ n你赢了$ 0;



我在这里得到一个错误代码。请帮帮我:(



我尝试了什么:



什么netbeans告诉我这样做。

解决方案

0;



我在这里得到一个错误代码请帮帮我:(



我尝试了什么:



netbeans告诉我要做什么。


如果您提供了例程的完整代码,收到的错误,netbeans告诉您要做什么以及结果,那将非常有用。 />


只要肉眼看看你有什么

  if ((word1! = word2)&&(word1!= word3)&&(word  2 != word3))
// 查看第三个比较:word 2^^^

还没有看到outputString的定义

并且对于声明的then部分没有结束}


作为补充观察,请注意: Java 字符串比较应使用等于 [ ^ ]方法,而不是 == 运算符。例如,请参阅如何比较Java中的字符串? - 堆栈溢出 [ ^ ]。

if( (word1 != word2) && (word1 != word3) && (word 2 != word3) ) {
outputString = outputString + "\n\nYou have won $0";

I am getting an error code here. please help me :(

What I have tried:

what netbeans has told me to do.

解决方案

0";

I am getting an error code here. please help me :(

What I have tried:

what netbeans has told me to do.


It would be REALLY helpful if you provided the full code of the routine, the error received, what netbeans told you to do along with the result

Just to the naked eye with what you have

if( (word1 != word2) && (word1 != word3) && (word 2 != word3) )
// look at the third comparison: "word 2"       ^^^

ALSO No definition seen for "outputString"
AND No closing "}" for the "then" portion of the statement


As an additional observation, please note: Java string comparison should be performed using the equals[^] method, not the == operator. See, for instance, How do I compare strings in Java? - Stack Overflow[^].


这篇关于如果声明带有字符串和&&的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆