Remove trailing comma from comma-separated string

前端 未结 16 887
生来不讨喜
生来不讨喜 2020-12-04 21:37

I got String from the database which have multiple commas (,) . I want to remove the last comma but I can\'t really find a simple way of doing it.

16条回答
  •  执笔经年
    2020-12-04 21:41

    I'm late on this thread but hope it will help to some one.......

    String abc = "kushalhs , mayurvm , narendrabz ,";
    
    if(abc.indexOf(",") != -1){
        abc = abc.substring(0,abc.length() - 1);
    }
    

提交回复
热议问题