Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static <T> List<String> toStringsList(List<T> list) {
        return list.stream().map(x -> x.toString()).collect(Collectors.toList());
    }

    public static <T> List<String> toStringsList(T[] array) {
        return Arrays.stream(array).map(x -> x.toString()).collect(Collectors.toList());
    }

    public static List<String> toStringsList(byte[] bytes) {
        List<String> strings = new ArrayList<>(bytes.length);
        for (byte item : bytes) {
            strings.add("" + item);
        }
        return strings;
    }
}