English 中文(简体)
简单 Java 运算符
原标题:Simple Java Operator Contradiction

这也许信息太少了... 但是为什么这个工作跟我预期的相反呢?

                if (indSTime[t] <= monthTotal) {

                    Log.d("indSTime", String.valueOf(indSTime[t++]));
                    Log.d("monthTotal", String.valueOf(monthTotal));

                    NewRate = Double.valueOf(indSRate[s]);
                    indApr[o] = NewRate;
                }

它的运行量大于或等于,不小于或等于月总数。

我有4的“ IndSTime” 设置为 4 。 所以Eclipse的Logcat 开始记录两个变量。

4, 4
4, 5
4, 6
4, 7

等...

似乎应该是

4 ,1
4, 2
4, 3
4, 4

停止。

我知道我上面没有添加多少代码吗?我眼前有什么东西失踪了吗?或者是什么原因?

最佳回答

它记录了完全合理的东西。

实际:

indSTime=4, monthTotal=4
indSTime=4, monthTotal=5
indSTime=4, monthTotal=6
indSTime=4, monthTotal=7

预期:

indSTime=4, monthTotal=1
indSTime=4, monthTotal=2
indSTime=4, monthTotal=3
indSTime=4, monthTotal=4

在所有 < em> 实际 < / em > 情况下, < code> indSTime 都小于或等于 < code> monthTotal ,完全如您的代码所示。

在您的 预期 输出中,您已经显示三个例子,其中 indSTime 大于 month Total 。

因此,要么你实际希望对方操作员(/他们 ), 要么你被你的伐木弄糊涂了, 要么你可能两者兼而有之。 不幸的是,你在这里没有展示任何背景,因此不可能确切地说问题在哪里 — — 但肯定不是爪哇本身。

问题回答

4 低于或等于4、5、6和7。

4 绝对是 not 低于或等于1、2或3。

为什么你认为应该相反呢?





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签