List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList(args); System.out.println("before: " + stringList); for (int i = 0; i < stringList.size(); ++i) { stringList.set(i, stringList.get(i).replaceAll("\\s+", "")); }/*from w ww. j a v a 2 s .c om*/ System.out.println("after : " + stringList); }
From source file:MainClass.java
public static void main(String[] a) { List list = Arrays.asList(new String[] { "A", "B", "C", "D" }); Object[] objArray = list.toArray(); for (Object obj : objArray) { System.out.println(obj);// ww w. java 2 s . c o m } String[] strArray = (String[]) list.toArray(new String[list.size()]); for (String string : strArray) { System.out.println(string); } }
From source file:Main.java
public static void main(String[] args) { List<Point> points = Arrays.asList(new Point(12, 2)); points.stream().map(p -> p.getX()).forEach(System.out::println); }
From source file:Main.java
public static void main(String args[]) { String s[] = { "a", "b", "c", "d" }; System.out.println(Arrays.asList(s).toString()); }
From source file:MainClass.java
public static void main(String[] a) { List l1 = Arrays.asList(new String[] { "A", "B", "C" }); List l2 = Arrays.asList(new String[] { "A", "C", "D" }); Collections.copy(l1, l2); // works Collections.copy(l2, l1); // System.out.println(l1);/*from w w w. j a va2 s . c o m*/ System.out.println(l2); }
From source file:MainClass.java
public static void main(String[] a) { List barFlies = Arrays.asList(new String[] { "A", "B", "C" }); Collections.reverse(barFlies); System.out.println(barFlies); }
From source file:Main.java
public static void main(String[] args) { List<String> list = Arrays.asList(args); Collections.sort(list);// www .ja v a 2 s .c om System.out.println(list); }
From source file:MainClass.java
public static void main(String[] a) { List list = Arrays.asList(new String[] { "A", "B", "C", "D" }); Iterator iter = list.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/* ww w . j a va2 s. c o m*/ }
From source file:MainClass.java
public static void main(String[] args) { List<String> argList = Arrays.asList(args); Collections.shuffle(argList); for (String arg : argList) { System.out.format("%s ", arg); }// w w w . j a v a 2s. co m System.out.println(); }
From source file:Main.java
public static void main(String[] args) { final List<String> fruits = Arrays.asList(new String[] { "A", "B", "C", "D" }); System.out.println(fruits);/*from w w w .ja v a 2 s .c om*/ System.out.println(merge(fruits, 1)); }