How to delete every 2nd character in a string?

前端 未结 5 2028
执念已碎
执念已碎 2020-12-21 05:48

How to delete every 2nd character in a string?

For example:

3030313535333635  -> 00155365
3030303336313435  -> 00036145
3032323437353530  ->         


        
5条回答
  •  天命终不由人
    2020-12-21 06:33

    String input = "3030313535333635";
    String result = "";
    for(int i = 1; i < 16; i +=2 )
    {
        result += input[i];
    }
    

提交回复
热议问题