は、だから私はendsWith()がなぜ||オペレーター?
String x = "[email protected]" // <--- it's .com
if (!x.trim().toUpperCase().endsWith(".COM"))
{
System.out.println("Your E-mail is missing a \".com\"");
}
else
{
System.out.println("Welcome, " + x);
}
を試してみましたが、私は他の引数を含むしようとすると、それは完全に罰金
を働いていた。しかし||オペレータは、それはすべての
String x = "[email protected]"; // <--- now it's .edu
if (!x.trim().toUpperCase().endsWith(".COM") || !x.trim().toUpperCase().endsWith(".EDU"))
{
System.out.println("Your E-mail is missing a \".com\"");
}
else
{
System.out.println("Welcome, " + x);
}
では動作しません、私はif文で
|| !x.trim().toUpperCase().endsWith(".EDU");
を含めて以来、私はあなたがしようとしている場合、私は
これらの2つの条件はお互いに排他的です。あなたの電子メールが '' .COM''と '' .EDU''の両方で終わることは決してないので、チェックは常に真です。 – f1sh
ここには論理的な問題があります。 – AxelH
'||'は、あなたが望むものは何で、どちらは '&& 'です – niceman