字符串数组:“从不使用在"i ++"处更改的值" [英] String array: 'The value changed at 'i++' is never used'

查看:68
本文介绍了字符串数组:“从不使用在"i ++"处更改的值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

String[] queries = new String[2];
int i = 0;
Boolean result;
queries[i++] = "<query 1>";
queries[i++] = "<query 2>"; //Warning shown here
result = dbOpenHelper.ExecuteMyTransaction(queries);

第二个 i ++ 突出显示,并显示警告永远不会使用在'i ++'处更改的值" .该代码是由另一个人编写的,据我所知,这里< query 1> < query 2> 被分配给 queries [1] queries [2] ,但是随后它必须显示错误,因为数组的大小为2.没有错误,这种情况使我感到困惑.我可以安全地删除第二个作业,还是将第一个作业更改为 queries [i] ?

The second i++ gets highlighted and the warning 'The value changed at 'i++' is never used' is shown. This code was written by another person, and to my knowledge, here <query 1> and <query 2> get assigned to queries[1] and queries[2] respectively, but then it must show an error, as the array is of size 2. There's no error and this kind of confuses me on what's happening here. Can I safely remove the second assignment, or change the first one to queries[i]?

推荐答案

该代码正确无误,您可以放心地忽略此警告,或仅将带下划线的 i ++ 替换为 i .

The code is correct and you can safely ignore this warning or replace underlined i++ with just i.

此警告仅表示由于在该范围内不再使用 i 变量,因此增加其值或不起作用均无效,并且毫无意义.

This warning simply indicates that as there's no further use of i variable in that scope, so incrementing its value or not makes no effect and is simply pointless.

这篇关于字符串数组:“从不使用在"i ++"处更改的值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆