How to do the opposite of StringBuilder append in Java?

前端 未结 4 379
后悔当初
后悔当初 2021-01-21 02:24

What would be the opposite of:

savedPlanets.append(planet.getDisplayName()+\",\");

I have a list and I am adding the name of the planet every t

4条回答
  •  鱼传尺愫
    2021-01-21 03:12

    I think you're using StringBuffer or something like that. It's not a good solution it this case, I would recommend you to use Set. http://docs.oracle.com/javase/6/docs/api/java/util/Set.html

    Implement it like this:

    Set planets = new HashSet();
    planets.add("a");
    planets.add("b");
    planets.remove("a");
    

提交回复
热议问题