I have a problem with displaying the elements of the ArrayList
in Java. While returning the ArrayList
when its called from the Views to BMIAnalyzier cl
I suppose you are new to java. You need to understand the basics first. For instance in your case, ArrayList is a collection which you use to hold multiple values of the same type. With your Records class you are extending the collection which is not required here.
public class Records extends ArrayList < Records > {
should be
public class Records {
Also, you should always provide content to your class Constructor otherwise no values would be set for the object.
public Records(String sid, Double h, Double w, Double bmi, String c) {
this.SubjectId = sid;
// set other values as well
}
And, find(String sid) is returning Records object
ArrayList < Records > arraylist = analyzier.find(choice[1]);
should be changed to
Records record = analyzier.find(choice[1]);
For printing the values of your Records object do as @Niklas suggested
The main mystery is that you have the Records
class extend ArrayList
. I have no idea why you are doing that, but in so, you are inheriting ArrayList
's toString()
method, which is what renders the []
, since the array is empty. You need to implement toString()
for the Records
class.
String toString() {
return subjectId + " " + height + " " + width + " " + bmianalyzier + " " + categories;
}