List of usage examples for java.util List add
boolean add(E e);
From source file:Main.java
public static void main(String args[]) { // create link list object List<Integer> list = new LinkedList<Integer>(); // populate the list list.add(-1); list.add(4);/*from w ww. j a v a2s .c o m*/ list.add(-5); list.add(1); System.out.println("Max value is: " + Collections.max(list)); }
From source file:Main.java
public static void main(String args[]) { List<String> arlst = new ArrayList<String>(); // populate the list arlst.add("CSS"); arlst.add("PHP"); arlst.add("HTML"); arlst.add("java2s.com"); // create typesafe view of the collection Collection<String> tslst = Collections.checkedCollection(arlst, String.class); System.out.println(tslst);//from w w w . ja v a2s. co m }
From source file:Main.java
public static void main(String[] args) { List<String> list = new ArrayList<String>(); // populate the list list.add("1"); list.add("2"); list.add("3"); list.add("4"); list.add("from java2s.com"); // create a synchronized list List<String> synlist = Collections.synchronizedList(list); System.out.println("Sunchronized list is :" + synlist); }
From source file:Main.java
public static void main(String[] argv) { DayOfWeek d = DayOfWeek.FRIDAY; List<DayOfWeek> l = new ArrayList<>(); l.add(d); System.out.println(getNextClosestDateTime(l, 22, 20)); }
From source file:DiagnosticDemo.java
public static void main(String[] args) { String sourceFile = "c:/HelloWorld.Java"; JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics); List<File> sourceFileList = new ArrayList<File>(); sourceFileList.add(new File(sourceFile)); Iterable<? extends JavaFileObject> compilationUnits = fileManager .getJavaFileObjectsFromFiles(sourceFileList); CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits); task.run();/*from ww w . j av a 2 s . c om*/ try { fileManager.close(); } catch (IOException e) { } List<Diagnostic<? extends JavaFileObject>> diagnosticList = diagnostics.getDiagnostics(); for (Diagnostic<? extends JavaFileObject> diagnostic : diagnosticList) { System.out.println("Position:" + diagnostic.getStartPosition()); } }
From source file:ID.java
public static void main(String[] args) throws IOException, ClassNotFoundException { ID id = new ID(); List employees = new ArrayList(); employees.add(new Employee("A", id)); employees.add(new Employee("B", id)); employees.add(new Employee("C", id)); System.out.println("employees: " + employees); ByteArrayOutputStream buf1 = new ByteArrayOutputStream(); ObjectOutputStream o1 = new ObjectOutputStream(buf1); o1.writeObject(employees);//from w w w. j ava 2s . c o m o1.writeObject(employees); ByteArrayOutputStream buf2 = new ByteArrayOutputStream(); ObjectOutputStream o2 = new ObjectOutputStream(buf2); o2.writeObject(employees); ObjectInputStream in1 = new ObjectInputStream(new ByteArrayInputStream(buf1.toByteArray())); ObjectInputStream in2 = new ObjectInputStream(new ByteArrayInputStream(buf2.toByteArray())); List emp1 = (List) in1.readObject(), emp2 = (List) in1.readObject(), emp3 = (List) in2.readObject(); System.out.println("emp1: " + emp1); System.out.println("emp2: " + emp2); System.out.println("emp3: " + emp3); }
From source file:Test.java
public static void main(String[] args) { List arrayList = new ArrayList<>(); //List<String> arrayList = new ArrayList<>(); arrayList.add("First"); arrayList.add("Second"); }
From source file:Main.java
public static void main(String[] args) throws JAXBException { JAXBContext context = JAXBContext.newInstance(PayTypeList.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); PayTypeList paymentType = new PayTypeList(); List<String> paymentTypes = new ArrayList<String>(); paymentTypes.add("one"); paymentTypes.add("two"); paymentTypes.add("three"); paymentType.setPayType(paymentTypes); m.marshal(paymentType, System.out); }
From source file:House.java
public static void main(String[] args) throws IOException, ClassNotFoundException { House house = new House(); List animals = new ArrayList(); animals.add(new Animal("Bosco the dog", house)); animals.add(new Animal("Ralph the hamster", house)); animals.add(new Animal("Fronk the cat", house)); System.out.println("animals: " + animals); ByteArrayOutputStream buf1 = new ByteArrayOutputStream(); ObjectOutputStream o1 = new ObjectOutputStream(buf1); o1.writeObject(animals);/* w w w . j a va2 s.co m*/ o1.writeObject(animals); // Write a 2nd set // Write to a different stream: ByteArrayOutputStream buf2 = new ByteArrayOutputStream(); ObjectOutputStream o2 = new ObjectOutputStream(buf2); o2.writeObject(animals); // Now get them back: ObjectInputStream in1 = new ObjectInputStream(new ByteArrayInputStream(buf1.toByteArray())); ObjectInputStream in2 = new ObjectInputStream(new ByteArrayInputStream(buf2.toByteArray())); List animals1 = (List) in1.readObject(), animals2 = (List) in1.readObject(), animals3 = (List) in2.readObject(); System.out.println("animals1: " + animals1); System.out.println("animals2: " + animals2); System.out.println("animals3: " + animals3); }
From source file:twiliotest.TwilioTest.java
public static void main(String[] args) throws TwilioRestException { TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); // Build a filter for the MessageList List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("Body", "Testssss")); params.add(new BasicNameValuePair("To", "+639234026357")); params.add(new BasicNameValuePair("From", "+14803761083")); MessageFactory messageFactory = client.getAccount().getMessageFactory(); Message message = messageFactory.create(params); System.out.println(message.getSid()); }