List of usage examples for java.util List add
boolean add(E e);
From source file:alfio.config.SpringBootLauncher.java
/** * Entry point for spring boot//from ww w . j a v a 2 s . c om * @param args original arguments */ public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler()); String profiles = System.getProperty("spring.profiles.active", ""); SpringApplication application = new SpringApplication(SpringBootInitializer.class, RepositoryConfiguration.class, DataSourceConfiguration.class, WebSecurityConfig.class, MvcConfiguration.class); List<String> additionalProfiles = new ArrayList<>(); additionalProfiles.add(Initializer.PROFILE_SPRING_BOOT); if ("true".equals(System.getenv("ALFIO_LOG_STDOUT_ONLY"))) { // -> will load application-stdout.properties on top to override the logger configuration additionalProfiles.add("stdout"); } if ("true".equals(System.getenv("ALFIO_DEMO_ENABLED"))) { additionalProfiles.add(Initializer.PROFILE_DEMO); } if ("true".equals(System.getenv("ALFIO_JDBC_SESSION_ENABLED"))) { additionalProfiles.add(Initializer.PROFILE_JDBC_SESSION); } application.setAdditionalProfiles(additionalProfiles.toArray(new String[additionalProfiles.size()])); ConfigurableApplicationContext applicationContext = application.run(args); ConfigurableEnvironment environment = applicationContext.getEnvironment(); log.info("profiles: requested {}, active {}", profiles, String.join(", ", (CharSequence[]) environment.getActiveProfiles())); if ("true".equals(System.getProperty("startDBManager"))) { launchHsqlGUI(); } }
From source file:Main.java
public static void main(String s[]) { DefaultTableModel model = new DefaultTableModel(); model.addColumn("Col1"); model.addColumn("Col2"); model.addRow(new Object[] { "1", "v2" }); model.addRow(new Object[] { "2", "v2" }); List<String> numdata = new ArrayList<String>(); for (int count = 0; count < model.getRowCount(); count++) { numdata.add(model.getValueAt(count, 0).toString()); }//from w w w. jav a 2 s .com System.out.println(numdata); }
From source file:Entity.java
public static void main(String[] args) { List<Entity> entities = new ArrayList<>(); entities = new ArrayList<>(); entities.add(new WorkerA()); entities.add(new WorkB()); gameEngine(entities);//from ww w. ja va2s. c o m }
From source file:SerializeJavaObjects_MySQL.java
public static void main(String args[]) throws Exception { Connection conn = null;// ww w . j av a2s .c o m try { conn = getConnection(); System.out.println("conn=" + conn); conn.setAutoCommit(false); List<Object> list = new ArrayList<Object>(); list.add("This is a short string."); list.add(new Integer(1234)); list.add(new Date()); long objectID = writeJavaObject(conn, list); conn.commit(); System.out.println("Serialized objectID => " + objectID); List listFromDatabase = (List) readJavaObject(conn, objectID); System.out.println("[After De-Serialization] list=" + listFromDatabase); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } }
From source file:LinkedListTest.java
public static void main(String[] args) { List<String> a = new LinkedList<String>(); a.add("Amy"); a.add("Carl"); a.add("Erica"); List<String> b = new LinkedList<String>(); b.add("Bob"); b.add("Doug"); b.add("Frances"); b.add("Gloria"); // merge the words from b into a ListIterator<String> aIter = a.listIterator(); Iterator<String> bIter = b.iterator(); while (bIter.hasNext()) { if (aIter.hasNext()) aIter.next();// w w w . ja v a 2s. com aIter.add(bIter.next()); } System.out.println(a); // remove every second word from b bIter = b.iterator(); while (bIter.hasNext()) { bIter.next(); // skip one element if (bIter.hasNext()) { bIter.next(); // skip next element bIter.remove(); // remove that element } } System.out.println(b); // bulk operation: remove all words in b from a a.removeAll(b); System.out.println(a); }
From source file:Main.java
public static void main(String[] args) { // create array list object List<Integer> numbers = new ArrayList<Integer>(); // populate the list for (int i = 0; i < 15; i++) { numbers.add(i); }//from w w w .j a v a2s . co m System.out.println("Before : " + Arrays.toString(numbers.toArray())); // rotate the list at distance 10 Collections.rotate(numbers, 10); System.out.println("After : " + Arrays.toString(numbers.toArray())); }
From source file:siddur.solidtrust.azure.AzureCarConstants.java
public static void main(String[] args) throws Exception { String url = OPENDATA_RWD_CSV_POST_URL; HttpPost request = new HttpPost(url); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("view", VIEW)); nvps.add(new BasicNameValuePair("method", METHOD)); request.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpClient httpClient = HttpClients.custom().build(); CloseableHttpResponse response = httpClient.execute(request); InputStream is = response.getEntity().getContent(); IOUtils.copy(is, System.out); }
From source file:Main.java
public static void main(String[] args) throws InterruptedException, ExecutionException { List<String> searchList = new ArrayList<String>(7); searchList.add("hello"); searchList.add("world"); searchList.add("CSS"); searchList.add("debian"); searchList.add("linux"); searchList.add("HTML"); searchList.add("stack"); Set<String> targetSet = new HashSet<String>(searchList); Set<String> matchSet = findMatches(searchList, targetSet); for (String match : matchSet) { System.out.println("match: " + match); }// w ww . j ava2s . c o m }
From source file:CollectionAll.java
public static void main(String[] args) { List list1 = new LinkedList(); list1.add("list"); list1.add("dup"); list1.add("x"); list1.add("dup"); traverse(list1);//from www . java 2s . c o m List list2 = new ArrayList(); list2.add("list"); list2.add("dup"); list2.add("x"); list2.add("dup"); traverse(list2); Set set1 = new HashSet(); set1.add("set"); set1.add("dup"); set1.add("x"); set1.add("dup"); traverse(set1); SortedSet set2 = new TreeSet(); set2.add("set"); set2.add("dup"); set2.add("x"); set2.add("dup"); traverse(set2); LinkedHashSet set3 = new LinkedHashSet(); set3.add("set"); set3.add("dup"); set3.add("x"); set3.add("dup"); traverse(set3); Map m1 = new HashMap(); m1.put("map", "Java2s"); m1.put("dup", "Kava2s"); m1.put("x", "Mava2s"); m1.put("dup", "Lava2s"); traverse(m1.keySet()); traverse(m1.values()); SortedMap m2 = new TreeMap(); m2.put("map", "Java2s"); m2.put("dup", "Kava2s"); m2.put("x", "Mava2s"); m2.put("dup", "Lava2s"); traverse(m2.keySet()); traverse(m2.values()); LinkedHashMap /* from String to String */ m3 = new LinkedHashMap(); m3.put("map", "Java2s"); m3.put("dup", "Kava2s"); m3.put("x", "Mava2s"); m3.put("dup", "Lava2s"); traverse(m3.keySet()); traverse(m3.values()); }
From source file:com.sankalp.characterreader.CharacterReader.java
public static void main(String[] args) throws IOException { double learningRate = 0.55; List<NeuralNetwork.Layer> hiddenLayerList = new ArrayList(); hiddenLayerList.add(new NeuralNetwork.Layer(50)); NeuralNetwork neuralNetwork = new NeuralNetwork(new NeuralNetwork.Layer(28 * 28), new NeuralNetwork.Layer(10), hiddenLayerList, learningRate); int trainingSampleCount = 60000; TrainingData trainingData = new TrainingData(new File("/home/sankalpkulshrestha/mnist/train-images/"), trainingSampleCount, new File("/home/sankalpkulshrestha/mnist/train-labels.csv")); int totalEpochs = 30; for (int index = 0; index < totalEpochs; index++) { System.out.println("---------- EPOCH " + index + " ----------"); neuralNetwork.train(trainingData); TrainingData testData = new TrainingData(new File("/home/sankalpkulshrestha/mnist/test-images/"), 10000, new File("/home/sankalpkulshrestha/mnist/test-labels.csv")); System.out.println("Training over"); double accuracy = neuralNetwork.measureAccuracy(testData); System.out.println(accuracy); if (index < totalEpochs - 1) { trainingData.shuffle();/* ww w. jav a 2s. c o m*/ trainingData.reset(); } } System.out.println("Model trained. Enter image file names:"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int number = -1; List<String> expectedOutputList = FileUtils .readLines(new File("/home/sankalpkulshrestha/mnist/test-labels.csv"), "UTF-8"); while ((number = Integer.parseInt(br.readLine())) != -1) { int output = neuralNetwork.test(new TrainingData.Sample( new File("/home/sankalpkulshrestha/mnist/test-images/" + number + ".jpg"), 0)); System.out.println(output); } }