Java被if语句卡住并混淆
我有点卡住了。我希望我的程序接受0和非0数字,但如果非0数字高于或低于某个整数,它将无法工作。希望这是有道理的
以下是我所拥有的:
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
谢谢你的帮助
# 1 楼答案
从另一个角度改变你的逻辑
正如@Vinod提到的
写得更好
如果这确实是你的意图