Directly use trim() to remove character from last of string
String a=1,2,3,4,5,;
I want to remove last ,
a.trim(); It'll get the task done