Java List Copy copyList(Object object)

Here you can find the source of copyList(Object object)

Description

copy List

License

LGPL

Declaration

public static List<String> copyList(Object object) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> copyList(Object object) {
        if (!(object instanceof List)) {
            return new ArrayList<>();
        }/*w w w. j av  a  2 s  .  c  o  m*/
        List<?> list = (List<?>) object;
        List<String> temp = new ArrayList<>();
        for (Object ob : list) {
            if (ob instanceof String) {
                temp.add((String) ob);
            } else if (ob == null) {
                temp.add(null);
            } else {
                return new ArrayList<>();
            }
        }
        return temp;
    }
}

Related

  1. copyList(List list)
  2. copyList(List list)
  3. copyList(List list)
  4. copyList(List master, List slave)
  5. copyList(List original)
  6. copyListOnlySpecified(List list, int[] indexes)
  7. copyListRaw(List master, List slave)
  8. copyNullable(List original)
  9. copyNullSafeMutableList(Collection list)