Example usage for java.util ArrayList ArrayList

List of usage examples for java.util ArrayList ArrayList

Introduction

In this page you can find the example usage for java.util ArrayList ArrayList.

Prototype

public ArrayList() 

Source Link

Document

Constructs an empty list with an initial capacity of ten.

Usage

From source file:stratego.neural.net.RandomSampleTest.java

public static void main(String[] args) {
    double[] wins = new double[data_points];
    double[] winrate = new double[data_points];
    List<double[]> data = new ArrayList<>();

    for (int i = 0; i < random.length; i++) {
        random[i] = new Random();
    }/*from  w  ww .  j a  v  a 2s  .c  o m*/

    for (int index = 0; index < repetitions; index++) {

        for (int i = 0; i < wins.length; i++) {
            wins[i] = (double) random[index].nextInt(2);
        }

        winrate[0] = wins[0];

        for (int i = 1; i < winrate.length; i++) {
            double total_wins = 0;
            for (int j = 0; j < i; j++) {
                total_wins = total_wins + wins[j];
            }
            winrate[i] = (total_wins / i);
        }

        data.add(winrate);
    }

    plotDataSet(data);
}

From source file:ShuffleTest.java

public static void main(String[] args) {
    List<Integer> numbers = new ArrayList<Integer>();
    for (int i = 1; i <= 49; i++)
        numbers.add(i);/* w w  w .j a va2s.c om*/
    Collections.shuffle(numbers);
    List<Integer> winningCombination = numbers.subList(0, 6);
    Collections.sort(winningCombination);
    System.out.println(winningCombination);
}

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());
}

From source file:com.di.bi.nextgen.installattribution.searchcountrycode.SearchCountryCode.java

public static void main(String[] args) throws Exception {
    Map<String, String> map = CSVReader();
    List<String> miss = new ArrayList<>();
    List<String[]> data = new ArrayList<>();
    String csv = "infinity.csv";
    CSVWriter writer = new CSVWriter(new FileWriter(csv));
    List<String[]> outList = new ArrayList<>();
    JSONArray arry = ReadJson();/* w  ww. ja  v  a 2  s.com*/
    for (String key : map.keySet()) {
        String[] arr = key.split(";");
        boolean isf = false;
        for (int i = 0; i < arry.length(); ++i) {
            JSONObject o = arry.getJSONObject(i);
            if (arr.length > 1) {
                if (o.keySet().contains(arr[1].toUpperCase())) {
                    System.out.println("arr[]1" + arr[1]);
                    System.out.println("o.keySet() " + o.keySet());
                    System.out.println(" bu " + o.keySet().contains(arr[1].toUpperCase()));
                    JSONArray arryC = o.getJSONArray(arr[1].toUpperCase());
                    for (int j = 0; j < arryC.length(); ++j) {
                        String[] tmp = { map.get(key) + "," + key + ";" + arryC.getString(j) };
                        outList.add(tmp);
                    }
                    isf = true;
                    break;
                }
            }
        }
        if (!isf) {
            miss.add(key);
            isf = false;
        }
    }
    writer.writeAll(outList);
    writer.close();
    System.out.println("Miissing" + miss);

}

From source file:fr.assoba.open.perf.GenDist.java

public static void main(String[] args) {
    // Magic number !
    LogNormalDistribution distribution = new LogNormalDistribution(6.73, 2.12);
    ArrayList<Long> list = new ArrayList<Long>();
    for (int i = 0; i < 1023; i++) {
        double d = (1.0 * i) / 1023.0;
        list.add((long) (100 * distribution.inverseCumulativeProbability(d)));
    }/*from w  w  w .j  av  a  2 s  .  c o  m*/
    System.out.print(Joiner.on(",").join(list));

}

From source file:Level.java

public static void main(String[] args) {
    Person one = new Person(Level.HIGH, "A");
    Person two = new Person(Level.MEDIUM, "B");
    Person three = new Person(Level.LOW, "C");
    Person four = new Person(Level.HIGH, "D");
    Person five = new Person(Level.MEDIUM, "E");
    Person six = new Person(Level.LOW, "F");
    Person seven = new Person(Level.LOW, "G");

    List<Person> persons = new ArrayList<Person>();
    persons.add(one);//from  w w w.j a  v  a 2s.  c  o  m
    persons.add(two);
    persons.add(three);
    persons.add(four);
    persons.add(five);
    persons.add(six);
    persons.add(seven);

    Collections.sort(persons, new Comparator<Person>() {
        @Override
        public int compare(Person person1, Person person2) {
            if (person1.getSeverity() == person2.getSeverity()) {
                return person1.getName().compareTo(person2.getName());
            } else {
                return person1.getSeverity().compareTo(person2.getSeverity());
            }
        }
    });
    for (Person person : persons) {
        System.out.println(person.getName() + " " + person.getSeverity());
    }
}

From source file:br.com.great.resource.Executa.java

/**
 *
 * @param args String/*from   w  w w  . ja v a  2 s.c om*/
 */
public static void main(String[] args) {
    Texto t = new Texto();
    t.setMecsimples_id(1);
    t.setTexto("aaaaaaaa");
    t.setCapturarObjeto(new CapturarObjeto());
    t.getCapturarObjeto().setTipo(99);
    t.getCapturarObjeto().setNome("carleandro");
    PlayJogo.getMecTextos().add(t);

    Missao m = new Missao();
    m.setMecanica(new ArrayList<Mecanica>());
    m.getMecanica().add(t.getCapturarObjeto());

    PlayJogo.getMissoes().add(m);

    System.err.println(PlayJogo.getMissoes().get(0).getMecanica().get(0).getNome());
    System.err.println(PlayJogo.getMecTextos().get(0).getCapturarObjeto().getNome());

    PlayJogo.getMecTextos().get(0).getCapturarObjeto().setNome("olivia");
    System.err.println(PlayJogo.getMissoes().get(0).getMecanica().get(0).getNome());
    System.err.println(PlayJogo.getMecTextos().get(0).getCapturarObjeto().getNome());
}

From source file:ArrayListTest.java

public static void main(String[] args) {
    // fill the staff array list with three Employee objects
    ArrayList<Employee> staff = new ArrayList<Employee>();

    staff.add(new Employee("Carl Cracker", 75000, 1987, 12, 15));
    staff.add(new Employee("Harry Hacker", 50000, 1989, 10, 1));
    staff.add(new Employee("Tony Tester", 40000, 1990, 3, 15));

    // raise everyone's salary by 5%
    for (Employee e : staff)
        e.raiseSalary(5);/*from  w w w  .  j a  v  a 2s  .c o  m*/

    // print out information about all Employee objects
    for (Employee e : staff)
        System.out.println("name=" + e.getName() + ",salary=" + e.getSalary() + ",hireDay=" + e.getHireDay());
}

From source file:ZipFileViewer.java

public static void main(String[] arg) throws Exception {
    String zipFileName = arg[0];//  w w  w . ja v  a2 s. c o  m
    List zipFileList = null;
    ZipFile zipFile = new ZipFile(zipFileName);
    Enumeration zipEntries = zipFile.entries();
    zipFileList = new ArrayList();
    while (zipEntries.hasMoreElements()) {
        zipFileList.add((ZipEntry) (zipEntries.nextElement()));
    }
    ZipFileViewer zipFileViewer = new ZipFileViewer(zipFileName, zipFileList);
}

From source file:Person.java

public static void main(String[] args) {
    SimpleDateFormat df = new SimpleDateFormat("mm-dd-yyyy");
    ArrayList<Person> people;
    people = new ArrayList<Person>();
    try {//from  ww w .j  av  a 2 s .co m
        people.add(new Person("A", 9, df.parse("12-12-2014")));
        people.add(new Person("B", 2, df.parse("1-12-2013")));
        people.add(new Person("C", 4, df.parse("12-2-2012")));
    } catch (ParseException e) {
        e.printStackTrace();
    }

    Collections.sort(people, new CompId());
    System.out.println("BY ID");
    for (Person p : people) {
        System.out.println(p.toString());
    }

    Collections.sort(people, new CompDate(false));
    System.out.println("BY Date asc");
    for (Person p : people) {
        System.out.println(p.toString());
    }
    Collections.sort(people, new CompDate(true));
    System.out.println("BY Date desc");
    for (Person p : people) {
        System.out.println(p.toString());
    }

}