java - How to convert ArrayList instanceObject to toString -
java - How to convert ArrayList instanceObject to toString -
i want convert instance of class in arraylist tostring have here code
user class:
public class user { // ... public void setname(string name) { this.fullname = name; } @override public string tostring() { homecoming this.fullname; } public arraylist<user> getthelikers() { arraylist<user> user = new arraylist<>(); user.add(this); homecoming user; }
post class:
public class post { public arraylist<user> getlikers() { user = new user(); arraylist<user> b = a.getthelikers(); homecoming b; }
and here code should getlikers()
while(rs.next()) { user = new user(); post b = new post(); string name = rs.getstring("people_who_like"); a.setname(name); arraylist c; c = b.getlikers(); string liker = c.tostring(); p.addelement(liker); }
i have convert tostring can see.. shows have display value in null
to convert arraylist
string
. question says.
arraylist c; c = b.getlikers(); string liker = ""; (string s : c){ liker += s + "\t"; }
java sql
Comments
Post a Comment