Java Collection to String toString(Collection collection, String prefix, String suffix)

Here you can find the source of toString(Collection collection, String prefix, String suffix)

Description

to String

License

Open Source License

Declaration

public static String toString(Collection<? extends Object> collection, String prefix, String suffix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

import java.util.List;

public class Main {
    public static String toString(Collection<? extends Object> collection, String prefix, String suffix) {
        StringBuilder sb = new StringBuilder();
        for (Object line : collection) {
            sb.append(prefix);//from   ww  w . ja  va 2 s  . c om
            sb.append(line.toString());
            sb.append(suffix);
        }
        return sb.toString();
    }

    public static String toString(List<List<String>> collection, String betweenElements, String betweenRows) {
        StringBuilder sb = new StringBuilder();
        for (List<String> row : collection) {
            sb.append(row.get(0));
            sb.append(betweenElements);
            sb.append(row.get(1));
            sb.append(betweenRows);
        }
        return sb.toString();
    }
}

Related

  1. toString(Collection collection, String separator, int fixedLength)
  2. toString(Collection objects)
  3. toString(Collection setOfTests)
  4. toString(Collection softwareTags)
  5. toString(Collection collection)
  6. toString(Collection c)
  7. toString(Collection c)
  8. toString(Collection collection)
  9. toString(Collection collection)