安卓:code的疯狂行为 [英] Android: code acts crazy
问题描述
我有一个非常奇怪的问题,同时努力开发基于Eclipse的Android
I have an extremely strange Problem, while trying to develop for android on eclipse
我的程序总是返回无感的语句,所以我试图调试它。
my program always returned non-sense statements, so I tried debugging it.
,现在我明白是什么问题....
...在code的作用字面上疯狂 - 这绝对是不合逻辑的。
And Now I understand what the problem is.... ...the code acts literally crazy - it's absolutely illogical
这是我的code:
ArrayList<String[]> formatedVerses = readAndSplitDatabaseFile(database, books);
if (formatedVerses.size() < 1) { // check if readAndSplitDatabaseFile worked
createDatabase(database, false); // if not. the database wasnt initialized
formatedVerses = readAndSplitDatabaseFile(database, books); // try again
}
return formatedVerses;
基本上我创建此ArrayList
但是,当我调试,它不只是去从上到下线槽code,它使怪异不合逻辑的跳跃
basically I create this ArrayList
But when I debug, it doesnt just go trough the code from top to bottom, it makes weird illogical jumps
调试器到达路线:
ArrayList<String[]> formatedVerses = readAndSplitDatabaseFile(database, books);
然后跳转到if语句(到目前为止好)
then jumps to the if-statement (so far so good)
if (formatedVerses.size() < 1) {
但formatedVerses.size()。1是假的,所以应该跳过if块
but "formatedVerses.size() < 1" is false, so it should jump over the if-block
而是调试器不仅一跃而起,如块,但它实际上跳入块的第二行:
but instead the debugger not only jumps INTO the if-block, but it actually jumps into THE SECOND LINE of the block:
formatedVerses = readAndSplitDatabaseFile(database, books);
这是没有任何意义。
which makes no sense whatsoever.
我觉得有人打趣我。
我只是不能换我的脑海里解决这个.....
I just cant wrap my mind around this.....
我也尝试重组code ...
但它只是变得怪异。
I've also tried restructuring the code... but it only gets weirder.
我也尝试过其他的实现。例如像这样的:
I've also tried other implementations. for example like this:
if (formatedVerses.size() < 1) {
return array1;
} else{
doSomethingElse();
return array2;
}
在这种情况下,跳转到如果块的真实陈述
in that case, it jumps into the true-statement of the if-block
return array1;
然后,当我点击下一步的,它实际上从该行跳到
else区块内的返回数组2
线,同时完全保留了 doSomethingElse()
直插
and then, when I click on next-step, it actually JUMPS from that line to the
return array2
line inside of the else-block, while completely leaving out the doSomethingElse()
-line
任何人有什么想法?
因为我现在要疯了吧......
anybody got any ideas? because I'm going crazy right now...
推荐答案
好吧,我想它了。
奇怪的是这是一件完全的不同。
Strangely it was something completely different.
我在我的程序的完整对方犯了一些错误。它只好自认倒霉code段做(没有问题,即使在同一个班级。)
I made some mistakes on the complete other side of my program. It had nothing to do with this code-segment (the problems weren't even in the same class.)
一旦固定,就又开始行动正常。
once that was fixed, it started to act normal again.
我不明白,在这一点上,我不想去了解它。
I don't understand it and at this point, I don't want to understand it.
感谢您的帮助,大家好。
Thanks for the help, everybody.
这篇关于安卓:code的疯狂行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!