开发者

How to remove comma from list of integers in java

I have a jsp page with dynamically created checkboxes. When we check boxes, a variable takes the corresponding emp id.

For example : I checked corresponding check boxes of emp id 2 and 4, then I will get an alert box with 2,4.

Now how can I remove the comma and pass values one开发者_如何学编程 after the other, since I want to extract the corresponding details of employee in the next jsp. I

I'm looking for the code in Java to remove comma from in between integers.


If you just want to replace the comma, you do:

String newOne = oldString.replaceAll(",","");

If you want to get each id in a new integer (which sounds more what you want from the description), you can do:

String[] ids = oldString.split(",");

you can then loop over the array to get the individual ids:

for (String id : ids ) {
   doSomethingWithId(id);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜