Salam ,
I'm new here , and i beleive I'll find my answer here ,
i hope you will help me.
I have data from a table in database.
this table contains ( id, name , age , class ) columns.
till now has 4 rows as well.
I created a java class called student :
------------------------------------- !/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package PG; /** * * @author VAIO */ public class Student { String id; String name; String age; String clas; public Student(String id, String name, String age, String clas) { this.id = id; this.name = name; this.age = age; this.clas = clas; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getClas() { return clas; } public void setClas(String clas) { this.clas = clas; } @Override public String toString() { return "Student{" + "id=" + id + ", name=" + name + ", age=" + age + ", clas=" + clas + '}'; } }
then i created Arraylist contains tables records ( but ) i inserted them student by student :
INFO: [Student{id=1, name=Ali, age=14, clas=A}, Student{id=2, name=Bdr, age=15, clas=B}, Student{id=3, name=Omar, age=13, clas=A}, Student{id=4, name=Bdr, age=12, clas=C}]
--------------------------
okey ! now i want to convert this arraylist to 2D array ,
because i want to compare first row with the rest , and then second one with the rest .. so on.
Object[][] ab = new Object[a.size()][4]; for (i = 0; i <a.size(); i++) { // will read the row System.out.print("i value:" + i); // will read col for (j = 0; j < 4; j++) { System.out.print("i value:" + i + "," + "j value:" + j); int y = 4 * i; // ab[i][j] = a.get(y + j); ab[i][j] = [[B] i could not complete this part[/B] ] ! } }
please will you help me ,
i hope you understand my point
thanks in advance.