1
以下是代码片段:爪哇 - 引用到数组
int[] cdb1 = {2,1,1,5,5};
int[] cbd2 = {3,1,1,2,2,6,6};
int[] cbd3 = {3,2,2,3,3,7,7};
int[] cbd4 = {2,3,3,4,4};
int[] cbd5 = {4,4,4,5,5,6,6,7,7};
String this_cdb = "cdb"+Integer.toString(router_id);
int this_cbd_number = this_cdb[0];
我收到以下错误:数组必需的,但字符串发现 int this_cbd_number = this_cdb[0];
这里router_id
可以1
2
3
4
或5
。我知道我宣称this_cdb
为String
。但是,我如何将它引用到正确的数组名称?
它应该是[router_id-1]对不对? – hnvasa
是的,你是对的,更正 –