List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:MainClass.java
public static void main(String[] a) { String elements[] = { "A", "B", "C", "D", "E" }; Set set = new HashSet(Arrays.asList(elements)); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/*from w w w.j a v a 2 s . c om*/ }
From source file:Copy.java
public static void main(String args[]) throws Exception { String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" }; Set set = new HashSet(Arrays.asList(elements)); Set set2 = ((Set) ((HashSet) set).clone()); System.out.println(set2);//from w ww. j a va2 s . c o m FileOutputStream fos = new FileOutputStream("set.ser"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(set); oos.close(); FileInputStream fis = new FileInputStream("set.ser"); ObjectInputStream ois = new ObjectInputStream(fis); Set set3 = (Set) ois.readObject(); ois.close(); System.out.println(set3); }
From source file:Main.java
public static void main(String[] argv) { List<String> sortedList = new LinkedList<String>(); sortedList.addAll(Arrays.asList(new String[] { "a", "b", "c", "d" })); int index = Collections.binarySearch(sortedList, "c"); System.out.println(index);//from w w w. j a va 2 s. c o m index = Collections.binarySearch(sortedList, "e"); System.out.println(index); }
From source file:Main.java
public static void main(String[] args) { Class cls = Thread.class; System.out.println("Class = " + cls.getName()); Class[] c = cls.getClasses(); System.out.println("Classes = " + Arrays.asList(c)); // returns an array of interfaces Class[] i = cls.getInterfaces(); System.out.println("Interfaces = " + Arrays.asList(i)); }
From source file:Main.java
public static void main(String[] argv) { List<String> sortedList = new LinkedList<String>(); sortedList.addAll(Arrays.asList(new String[] { "a", "b", "c", "d" })); int index = Collections.binarySearch(sortedList, "c"); System.out.println(index);/*from ww w . j a v a2 s . c o m*/ index = Collections.binarySearch(sortedList, "e"); System.out.println(index); }
From source file:Main.java
public static void main(String args[]) { String a[] = { "a", "b", "c" }; String b[] = { "d", "e" }; List<String> list = new ArrayList<String>(Arrays.asList(a)); list.addAll(Arrays.asList(b)); Object[] c = list.toArray();/*from w w w.j a va 2 s . com*/ System.out.println(Arrays.toString(c)); }
From source file:NameSort.java
public static void main(String args[]) { String n[] = new String[] { "John", "Lennon", "Karl", "Marx", "Groucho", "Marx", "Oscar", "Grouch" }; List l = Arrays.asList(n); Collections.sort(l);//w w w.j a v a2 s . com System.out.println(l); }
From source file:Main.java
public static void main(String args[]) { // create an array of strings String a[] = new String[] { "CSS", "HTML", "Python", "tutorial from java2s.com" }; List<String> list1 = Arrays.asList(a); // printing the list System.out.println("The list is:" + list1); }
From source file:Main.java
public static void main(String[] argv) throws Exception { List<String> sortedList = new LinkedList<String>(); sortedList.addAll(Arrays.asList(new String[] { "a", "b", "c", "d" })); int index = Collections.binarySearch(sortedList, "c"); index = Collections.binarySearch(sortedList, "cc"); }
From source file:Main.java
public static void main(String[] a) { String elements[] = { "A", "B", "C", "D", "E" }; HashSet<String> set = new HashSet<String>(Arrays.asList(elements)); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }//from w w w . j a v a 2 s.c o m }