HOW TO REMOVE COMMA FROM ARRAY LIST?

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 3051  View(s)
Ratings:
Rate this:
I have an Arraylist where I place float values.

xEvent.add(fileTimeStamp);
            xEvent.add(x);
            xEvent.add(zCSV + "\n");


    String formatedString = xEvent.toString()
                                .replace("[", "") // remove the right bracket
                                .replace("]", "") // remove the left bracket
The problem is that the Arraylist places a comma to separate values. How can I get rid of this comma without getting rid of the comma that in some locales is used as the decimal mark? On the U.S. we use the period as the decimal mark, so removing all commas would work, however on countries where they use the comma as the decimal mark I would end up ruining the data.
  1. Samuel Fernandes

    Post:159

    Points:1117
    Re: How to remove comma from array list?

    I'm not sure you can errase the ',' from the to string without ruining the data, I would recomend using a for() to get the information

    String formatedString="";
    for(String s: xEvent){
        formatedString += s;
    }
    Like this you will get all the information inside a String without the ']','[' or ','. Hope it helps you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!