Results 1 to 2 of 2
  1. #1
    tmotse is offline Member
    Join Date
    Mar 2010
    Posts
    17
    Rep Power
    0

    Default String Manipulation

    Hello Guys

    i have a code like this

    import java.util.ArrayList;
    public class Test {
    public static void main(String[] args) {
    ArrayList<String> array = new ArrayList<String>();
    array.add("A");
    array.add("E");
    array.add("X");
    array.add("*");
    System.out.println("Contents of array:" + array);

    }
    }

    and returns
    Contents of array:[A, E, X, *]

    what i want to do is to return [A, E, X, *]like this ['A',' E',' X',' *']

    thank you:

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Loop through the list, and format in the way you want. Don't use + operator to concatenate strings, use StringBuffer instead.

    Or else formatter class, which I really like to use.

    Formatter (Java 2 Platform SE 5.0)

Similar Threads

  1. Help needed with string manipulation
    By stringkilla in forum New To Java
    Replies: 47
    Last Post: 09-07-2010, 03:25 AM
  2. Image manipulation
    By spike72 in forum Java 2D
    Replies: 1
    Last Post: 08-28-2009, 08:45 PM
  3. Array manipulation
    By Ms.Ranjan in forum New To Java
    Replies: 9
    Last Post: 07-18-2008, 09:10 PM
  4. String manipulation example (Title case)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 09:04 AM
  5. String Manipulation Task
    By hiranya in forum New To Java
    Replies: 1
    Last Post: 11-19-2007, 11:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •