Java List to String listToString(List list)

Here you can find the source of listToString(List list)

Description

list To String

License

Open Source License

Declaration

public static String listToString(List<Integer> list) 

Method Source Code

//package com.java2s;

import java.util.Iterator;

import java.util.List;

public class Main {

    public static String listToString(List<Integer> list) {
        String str = "";
        if ((list != null) && (list.size() > 0)) {
            for (Iterator i$ = list.iterator(); i$.hasNext();) {
                int id = ((Integer) i$.next()).intValue();
                str = str + id + ",";
            }/*from  w w w.ja v  a  2 s . c o m*/
            if ((!("".equals(str))) && (str.length() > 0))
                str = str.substring(0, str.length() - 1);
        }
        return str;
    }

    public static boolean equals(String s1, String s2) {
        if ((isEmpty(s1)) && (isEmpty(s2)))
            return true;
        if ((!(isEmpty(s1))) && (!(isEmpty(s2))))
            return s1.equals(s2);

        return false;
    }

    public static boolean isEmpty(String s) {
        return ((s == null) || ("".equals(s)));
    }

    public static String isEmpty(String s, String result) {
        if ((s != null) && (!(s.equals(""))))
            return s;

        return result;
    }
}

Related

  1. listToString(List list)
  2. listToString(List list)
  3. listToString(List list, String separator, String prefix, String suffix)
  4. listToString(List list, String seperator)
  5. listToString(List list)
  6. listToString(List list, String operator)
  7. listToString(List value)
  8. listToString(List args)
  9. listToString(List l, String sep)

  10. HOME | Copyright © www.java2s.com 2016