Example usage for java.util ArrayList remove

List of usage examples for java.util ArrayList remove

Introduction

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

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the first occurrence of the specified element from this list, if it is present.

Usage

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> arrayList = new ArrayList<String>();

    arrayList.add("1");
    arrayList.add("2");
    arrayList.add("3");

    Object obj = arrayList.remove(1);
    System.out.println(obj + " is removed from ArrayList");

    for (String str : arrayList)
        System.out.println(str);/* w w  w .j  a  v  a  2  s. com*/
}

From source file:dk.dma.nogoservice.Application.java

public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
    ArrayList<String> profiles = Lists.newArrayList(ApiProfiles.PRODUCTION, ApiProfiles.SECURITY);
    if (Boolean.getBoolean("disableSecurity")) {
        profiles.remove(ApiProfiles.SECURITY);
    }/*from ww w  .ja v a  2s .c o m*/
    builder.profiles(profiles.toArray(new String[profiles.size()])).headless(false).run(args);
}

From source file:Main.java

public static void main(String[] args) {

    ArrayList<Integer> arrlist = new ArrayList<Integer>(5);

    arrlist.add(20);//from  w  w  w. j a v a2 s.com
    arrlist.add(15);
    arrlist.add(30);
    arrlist.add(45);

    System.out.println("Size of list: " + arrlist.size());
    System.out.println(arrlist);

    arrlist.remove(2);

    System.out.println("Size of list: " + arrlist.size());
    System.out.println(arrlist);

}

From source file:MainClass.java

public static void main(String[] a) {
    ArrayList<Employee> emps = new ArrayList<Employee>();

    Employee emp1 = new Employee("A", "G");
    Employee emp2 = new Employee("T", "A");
    Employee emp3 = new Employee("K", "J");

    emps.add(emp1);//from w ww .ja v  a 2  s.c o  m
    emps.add(emp2);
    emps.add(emp3);

    System.out.println(emps);

    emps.remove(emp2);

    System.out.println(emps);
}

From source file:challenge302.intermediate.ASCIIHistogramMaker.java

public static void main(String[] args) {
    String inFile = "/data/challenge302intermediate.txt";

    //        ArrayList<int[]> graphData = new ArrayList<int[]>();
    ArrayList<String> input = new ChallengeInput().getInputByLines(ASCIIHistogramMaker.class, inFile);
    //take first line as the chart bounds and create new BarChart with those bounds
    IntBasedBarChart chart = new IntBasedBarChart(input.remove(0).split(" "));

    //take next line as the number of chart elements
    int size = Integer.parseInt(input.remove(0));

    for (int i = 0; i < size; i++) {
        //            System.out.println("Parsing: graph data line=\""+input.get(i)+"\"");
        chart.addData(stringArraytoIntArray(input.get(i).split(" ")));
    } //end adding all lines

    printChart(chart, size);/*from  w ww .  j a v a2s .c  o m*/

}

From source file:Main.java

public static void main(String[] args) {

    ArrayList<String> arrlist = new ArrayList<String>(5);

    arrlist.add("G");
    arrlist.add("E");
    arrlist.add("F");
    arrlist.add("M");
    arrlist.add("E");
    arrlist.add("from java2s.com");

    System.out.println("Size of list: " + arrlist.size());

    System.out.println(arrlist);/*  w ww .java2  s . c  o  m*/

    // Removes first occurrence of "E"
    boolean value = arrlist.remove("E");

    System.out.println("Now, Size of list: " + arrlist.size());

    System.out.println("Value = " + arrlist);
}

From source file:Main.java

public static void main(String args[]) {
    ArrayList<String> al = new ArrayList<String>();

    System.out.println("Initial size of al: " + al.size());

    al.add("C");/*from   w ww .j  a v a 2 s  .c o  m*/
    al.add("A");
    al.add("E");
    al.add("B");
    al.add("D");
    al.add("F");
    al.add(1, "java2s.com");

    System.out.println("Size of al after additions: " + al.size());

    System.out.println("Contents of al: " + al);

    al.remove("F");
    al.remove(2);

    System.out.println("Size of al after deletions: " + al.size());
    System.out.println("Contents of al: " + al);
}

From source file:MainClass.java

public static void main(String args[]) {
    ArrayList<String> al = new ArrayList<String>();

    System.out.println("Initial size of al: " + al.size());

    al.add("C");/*from w ww  .j  av  a2s  . c  o m*/
    al.add("A");
    al.add("E");
    al.add("B");
    al.add("D");
    al.add("F");
    al.add(1, "A2");

    System.out.println("Size of al after additions: " + al.size());

    System.out.println("Contents of al: " + al);

    al.remove("F");
    al.remove(2);

    System.out.println("Size of al after deletions: " + al.size());
    System.out.println("Contents of al: " + al);
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> list = new ArrayList<>();
    list.add("A");
    list.add("B");
    list.add("C");
    list.add("D");
    list.add("E");
    list.add("F");
    list.add("G");
    list.add("H");

    System.out.println(list);//from   www  .  j  a v a 2  s .co  m

    while (!list.isEmpty()) {
        long index = Math.round(Math.floor(Math.random() * list.size()));
        System.out.println("Name " + list.get((int) index));
        list.remove((int) index);
    }

}

From source file:com.talkdesk.geo.PhoneNumberGeoMap.java

/**
 * @param args//from  ww  w .  ja v  a2s . co m
 * @throws IOException
 * @throws SQLException
 * @throws ClassNotFoundException
 * @throws GeoResolverException
 */
public static void main(String[] args) throws GeoResolverException {
    // create Options object
    DBConnector connector = new DBConnector();
    GeoCodeResolver resolver = new GeoCodeResolver(connector.getDefaultDBconnection());
    ArrayList list = new ArrayList(Arrays.asList(args));
    Hashtable<String, Double> infoTable = new Hashtable<String, Double>();

    if (list.contains("--populate-data")) {
        GeoCodeRepositoryBuilder repositoryBuilder = new GeoCodeRepositoryBuilder();
        if (list.contains("--country"))
            repositoryBuilder.populateCountryData();
        else if (list.contains("--geo"))
            repositoryBuilder.populateGeoData();
        else {
            repositoryBuilder.populateCountryData();
            repositoryBuilder.populateGeoData();
        }

    } else if (list.contains("--same-country-only")) {
        list.remove("--same-country-only");
        infoTable = resolver.buildInfoTable(list, true);
    } else {
        infoTable = resolver.buildInfoTable(list, false);
    }

    String phoneNumber = resolver.getClosestNumber(infoTable);

    if (phoneNumber != null) {
        System.out.println("-----------------------");
        System.out.println(phoneNumber);
        Locale locale = new Locale("en", phoneNumber.split(":")[0]);
        System.out.println(locale.getDisplayCountry());
    } else {
        System.out.println("-----------------------");
        System.out.println("No Result ..!!!");
    }

}