-2
我有点卡住了。我想我的程序接受0和非0数字,但如果非0数字高于或低于某个整数,它将无法工作。希望这是有道理的。Java - 卡住并与if语句混淆
这是我有:
if (pos != 0 || pos == 0)
{
System.out.println ("\nLength of int: " + len);
System.out.println ("Position from right: " + pos);
System.out.println ("Number selected: " + String.valueOf (nums).charAt (s));
}
else if (pos < len || pos > len)
{
System.out.println ("\n0");
}
如果有人希望看到完整的代码,它是在这里:http://pastebin.com/bFVYNhvr
任何帮助表示赞赏
'POS!= 0 || pos == 0' [始终为真](https://en.wikipedia.org/wiki/Law_of_excluded_middle) – dasblinkenlight
'pos'是一个'int' - 因为它可以接受'0'和'非0'数字 –