Java List Join join(List lst, int start, int end)

Here you can find the source of join(List lst, int start, int end)

Description

join

License

Apache License

Declaration

public static String join(List<String> lst, int start, int end) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String join(List<String> lst, int start, int end) {
        return join(lst, start, end, " ");
    }/* ww w. ja v  a 2 s.  c  o  m*/

    public static String join(List<String> lst, int start, int end, String delim) {
        String res = "";

        if (start < 0) {
            start = 0;
        }

        if (end >= lst.size()) {
            end = lst.size() - 1;
        }

        if (start > end) {
            return res;
        } else {
            res = (String) lst.get(start);
            for (int i = start + 1; i <= end; i++) {
                res += delim + (String) lst.get(i);
            }
            return res;
        }
    }

    public static String join(List<String> lst, String delim) {
        String res = "";

        if (lst.size() > 0) {
            res = lst.get(0);
        }
        for (int i = 1; i < lst.size(); i++) {
            res += delim + lst.get(i);
        }

        return res;
    }

    public static String join(List<String> lst) {
        return join(lst, " ");
    }
}

Related

  1. join(List list, String sep)
  2. join(List list, String separator)
  3. join(List list, String separator)
  4. join(List list1, List list2)
  5. join(List list1, List list2)
  6. join(List lst, String separator)
  7. join(List members, boolean quote)
  8. join(List p_sStrList, String p_sDelimiter)
  9. join(List parts, String separator)