android上运行compare,java - android compare arrays - Stack Overflow

As I am not the best in android development, I tried something that works for me and for friend's mobile, but i have some reports from market that it doesn't work for all devices maybe and do wrong compare. Anyway. the project is simple, it grabs an order from sql and in the game the player try to finish it. So I have 2 arrays. I call this at start:

final String[] combo = new String[] {"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"};

final String[] order1 = new String[] {"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"};

for(int i = 0; i < combo.length; i++) {

combo[i] = new String();

combo[i] = "0";

order1[i] = new String();

order1[i] = "0";

}

and during the game if the player clicks a button it changes the value of combo, for example, combo[7] = "1";

When he click the final button I check that 2 arrays with this

String IsSame = compareOrder(combo, order1);

and then

if (IsSame.equals("TRUE")) {

// commands

}

else if (IsSame.equals("FALSE")) {

// commands

}

private String compareOrder(String[] a, String[] b){

String n1 = "TRUE";

for (int i = 0; i < 13; i++) {

if (a[i].equals(b[i])==false) {n1 = "FALSE";}

}

return n1;

}

It looks ok for me, and it's working for my mobile, but maybe the code is not so normal and it cause wrong results in other devices. So, I need help, if you see something strange and not working in my code, tell me. Thank you!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值