Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Create-an-HTML-table/Java/create-an-html-table-3.java
Normal file
25
Task/Create-an-HTML-table/Java/create-an-html-table-3.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
public class HTML {
|
||||
|
||||
public static String array2HTML(Object[][] array){
|
||||
StringBuilder html = new StringBuilder(
|
||||
"<table>");
|
||||
for(Object elem:array[0]){
|
||||
html.append("<th>" + elem.toString() + "</th>");
|
||||
}
|
||||
for(int i = 1; i < array.length; i++){
|
||||
Object[] row = array[i];
|
||||
html.append("<tr>");
|
||||
for(Object elem:row){
|
||||
html.append("<td>" + elem.toString() + "</td>");
|
||||
}
|
||||
html.append("</tr>");
|
||||
}
|
||||
html.append("</table>");
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
Object[][] ints = {{"","X","Y","Z"},{1,1,2,3},{2,4,5,6},{3,7,8,9},{4,10,11,12}};
|
||||
System.out.println(array2HTML(ints));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue