英文:
how to add in a loop for string and int in java
问题
i have this code:
int[] arr = new int[] {0254,0156,0641,0974,0112};
html.append("<table border=1 valign=\"center\" width=270 height=30
background=\"L2UI_CT1.Windows_DF_Drawer_Bg\">");
html.append("<tr>");
for(int i:arr){
html.append("<td width=30><img src=\"icon.customtex_" + i + "\" width=32 height=32></td>");
html.append("<td align=\"center\" width=290>" + arr2[i] + "</td>");
}
html.append("</tr>");
html.append("</table>");
i need change "Name 1" equivalent INT result
for example:
String[] arr2 = new String[] {"Name 1","Name 2","Name 3","Name 4","Name 5"};
英文:
i have this code:
int[] arr = new int[] {0254,0156,0641,0974,0112};
html.append("<table border=1 valign=\"center\" width=270 height=30
background=\"L2UI_CT1.Windows_DF_Drawer_Bg\">");
html.append("<tr>");
for(int i:arr){
html.append("<td width=30><img src=\"icon.customtex_" + i + "\" width=32 height=32></td>");
html.append("<td align=\"center\" width=290>Name 1</td>");
}
html.append("</tr>");
html.append("</table>");
i need change "Name 1" equivalent INT result
for example:
String[] arr2 = new String[] {"Name 1","Name 2","Name 3","Name 4","Name 5"};
答案1
得分: 0
你只需要这样做:
for(int i=0; i<arr.length; i++){
html.append("<td width=30><img src=\"icon.customtex_" + arr[i] + "\" width=32 height=32></td>");
html.append("<td align=\"center\" width=290>" + arr2[i] + "</td>");
}
英文:
You just need to do this:
for(int i=0; i<arr.length; i++){
html.append("<td width=30><img src=\"icon.customtex_" + arr[i] + "\" width=32 height=32></td>");
html.append("<td align=\"center\" width=290>" + arr2[i] + "</td>");
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论