commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [lang]
Date Thu, 20 Jun 2013 15:11:50 GMT
Hello Thomas,

how about java.util.Arrays.asList(T...)?

Regards,
Benedikt


2013/6/20 Thomas Lionel SMETS (prof) <tsmets@a3-system.eu>

>  Hello,
> I have been looking for a method allowing me to convert a String[] into a
> List.
> As I could not find it on ArrayUtils, here is a small piece of code I
> wrote :
>
>     /**
>      * Converts a <code>String[]</code> into a <code>List</code>.
>      * @param array the <code>String[]</code> to convert.
>      * @return <code>null</code> if the reference provided is
> <code>null</code>, otherwise a <code>List</code> with the content
of the
> array's elements.
>      */
>     public static List<String> convertArrayToList(String[] array)
>     {
>         if (array==null)
>             return null;
>
>         List<String> list = new ArrayList<String>(array.length);
>         for (int i = 0; i < array.length; i++) {
>             list.add(array[i]);
>         }
>
>         return list;
>     }
>
> This is provided "as is" under the following licence :
> http://www.apache.org/licenses/
>
> Enjoy,
>
> \T,
>
>
> --
> Thomas Lionel SMETS, CISSP (385434)
> *m :* +32 497 44 68 12
> *ph :* +32 2 852 3341
> *skype :* thomas.lionel.smets
>
> PGP = FDF0 8FB8 4F37 3F79 1011 05AB 0DCE 9BAB 5DD0 0E10
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message