StarSCreams Posted May 4, 2020 Posted May 4, 2020 hi, any can help me with this? 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 loop for 5 differents names.. but i no have idea how to make this.. thanks Quote
0 TGSLineage2 Posted May 5, 2020 Posted May 5, 2020 I don't quite understand what you want, but there you are creating a table with 1 row and 10 columns Quote
0 StarSCreams Posted May 5, 2020 Author Posted May 5, 2020 if any have this idea, i solved with this.. int[] arr = new int[] {0254,0156,0641,0974,0112}; String[] arr2 = new String[] {"A","B","C","D","E"}; 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>"); } locked. Quote
0 melron Posted May 5, 2020 Posted May 5, 2020 2 hours ago, StarSCreams said: if any have this idea, i solved with this.. int[] arr = new int[] {0254,0156,0641,0974,0112}; String[] arr2 = new String[] {"A","B","C","D","E"}; 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>"); } locked. Your code cant run that way, an int that starts with 09 is just not allowed in this specific example. If you need '0' at the begging of of any int, you should format it. ex: Arrays.asList(254,156,641,974,112).forEach(val -> html.append(String.format("<td width=30><img src=\"icon.customtex_%s\" width=32 height=32></td>",String.format("0%s", val)))); Arrays.asList("A","B","C","D","E").forEach(val -> html.append(String.format("<td align=\"center\" width=290>%s</td>",val))); Quote
0 StarSCreams Posted May 5, 2020 Author Posted May 5, 2020 29 minutes ago, melron said: Your code cant run that way, an int that starts with 09 is just not allowed in this specific example. If you need '0' at the begging of of any int, you should format it. ex: Arrays.asList(254,156,641,974,112).forEach(val -> html.append(String.format("<td width=30><img src=\"icon.customtex_%s\" width=32 height=32></td>",String.format("0%s", val)))); Arrays.asList("A","B","C","D","E").forEach(val -> html.append(String.format("<td align=\"center\" width=290>%s</td>",val))); hey bro the int numbers are only example, but i learn if need 0 at the begging thank you =) Quote
0 Tryskell Posted May 5, 2020 Posted May 5, 2020 Or simply store a String and not an int, which avoid format operations. To avoid to get inconsistencies between the 2 String array, you can also store it under a pair of String/String, or a Map<String, String> / String[][] - at least the result is reliable and data stays consistant. Quote
Question
StarSCreams
hi, any can help me with this?
have this code
i need loop for 5 differents names.. but i no have idea how to make this..
thanks
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.