Link to home
Start Free TrialLog in
Avatar of rajannagpal
rajannagpal

asked on

Arraylist into comma seprated list

I have an arraylist of salesCycle object  and I want to convert this arraylist into a comma separated String. For example:
Arraylist of sales Cycle and salesCycle has one of the property cycleID  I need the following result :

String cycles =salesCycle.cycleId1, salesCycle.cycleId2,&
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can do the following if your salesCycle object implements toString properly:

String cycles = list.toString();

Open in new window

Avatar of rajannagpal
rajannagpal

ASKER

what should under toString  method of salesCycle?
The representation you want it to have, e.g.
publ
public String toString() {
    return "" + id;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial