在线求高手解答。
/**输出效果:* 1 全国区域 null
* 2 华东区 1
* 3 东北区 1
* 4 上海市 2
* 5 杭州市 2
* 6 上海浦东 4
* 7 华南区 1
* 8 华北区 1
* 9 北京朝阳 18
* 10 天津市 8
* 11 长春市 3
* 12 上海黄浦 4
* 13 沈阳市 3
* 14 哈尔滨 3
* 15 北京海淀区 18
* 16 广州市 7
* 17 佛山市 7
* 18 北京市 8
* 19 南京市 2
*
*/
//以下是原题给好的代码框架。
public class myExam1 {
private String[][] str_data1 = new String[][]{
{"ROOT","全国区域",null},
{"HDQ","华东区","ROOT"},
{"DBQ","东北区","ROOT"},
{"SHS","上海市","HDQ"},
{"HZS","杭州市","HDQ"},
{"SH_PD","上海浦东","SHS"},
{"HNQ","华南区","ROOT"},
{"HBQ","华北区","ROOT"},
{"BJ_CY","北京朝阳","BJS"},
{"TJS","天津市","HBQ"},
{"CCS","长春市","DBQ"},
{"SH_HP","上海黄浦","SHS"},
{"SYS","沈阳市","DBQ"},
{"HEB","哈尔滨","DBQ"},
{"BJ_HD","北京海淀","BJS"},
{"GZS","广州市","HNQ"},
{"FSS","佛山市","HNQ"},
{"BJS","北京市","HBQ"},
{"NJS","南京市","HDQ"},
};
private String[][] str_data2 = new String[str_data1.length][3];
private int li_newPK = 0; //记录新主键的递增计数器;
public myExam1()
{
for(int i=0;i<str_data2.length;i++)
{
System.out.println(str_data2[i][0]+"\t"+str_data2[i][1]+"\t"+str_data2[i][2]);
}
}
private String getNewPK()
{
li_newPK++;
return ""+li_newPK;
}
public static void main(String args[])
{
}
} --------------------编程问答-------------------- 没说问题?
什么问题? --------------------编程问答-------------------- 是补充代码吧?
for(int i=0;i<str_data2.length;i++)
{
str_data2[i][0] = getNewPK(); //追加1
str_data2[i][1] = str_data1[i][1]; //追加2
str_data2[i][2] = str_data1[i][2]; //追加3
System.out.println(str_data2[i][0]+"\t"+str_data2[i][1]+"\t"+str_data2[i][2]);
}
public static void main(String args[])
{
new myExam1(); //追加4
}
补充:Java , Java SE