Example usage for java.util ArrayList size

List of usage examples for java.util ArrayList size

Introduction

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

Prototype

int size

To view the source code for java.util ArrayList size.

Click Source Link

Document

The size of the ArrayList (the number of elements it contains).

Usage

From source file:eurecom.constrained.devices.MainReasonSensorData.java

public static void main(String[] args) {
    //String sensor_data = WSUtils.queryWebServiceJSON(RASPBERRYPI_WEATHER_LUMINOSITY);
    String sensor_data = ReadFile.readContentFile(SENSOR_DATA_FILE);
    ConvertRaspberrySensorData converter = new ConvertRaspberrySensorData();
    Model model;/*  w w  w .  j a  v  a2  s.  co  m*/
    try {
        model = converter.convertRaspberrySensorDataToRDF(sensor_data, M3_RULES_PATH);

        //load the M2M measurement
        M2MAppGeneric m2mappli = new M2MAppGeneric(model);

        //load domain specific datasets and ontologies
        ReadFile.enrichJenaModelOntologyDataset(m2mappli.model, M3_ONTOLOGY_PATH);//no need
        ReadFile.enrichJenaModelOntologyDataset(m2mappli.model, TRANSPORT_ONTOLOGY_PATH);
        ReadFile.enrichJenaModelOntologyDataset(m2mappli.model, TRANSPORT_DATASET_PATH);
        ReadFile.enrichJenaModelOntologyDataset(m2mappli.model, WEATHER_ONTOLOGY_PATH);
        ReadFile.enrichJenaModelOntologyDataset(m2mappli.model, WEATHER_DATASET_PATH);

        //variable in the sparql query
        ArrayList<VariableSparql> var = new ArrayList<VariableSparql>();
        var.add(new VariableSparql("inferTypeUri", Var.NS_M3 + "WeatherLuminosity", false));
        var.add(new VariableSparql("typeRecommendedUri", Var.NS_TRANSPORT_ONTOLOGY + "SafetyDevice", false));//SafetyDevice

        Model inf = m2mappli.reasonWithJenaRules(LOR_FILE_PATH);//reasoner for jena rules //Var.LINKED_OPEN_RULES
        ExecuteSparqlGeneric reqSenml = new ExecuteSparqlGeneric(inf, SPARQL_QUERY_WEATHER_SAFETY_DEVICES_PATH);

        ArrayList<ResultSensorDataReasoning> resultAfterReasoning = reqSenml.getSelectResultAnsParseIt(var);
        for (int i = 0; i < resultAfterReasoning.size(); i++) {
            System.out.println(resultAfterReasoning.get(i).toString());
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] args) {

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

    arrlist.add(10);/*from  w ww  . j  a va 2s  .  c om*/
    arrlist.add(12);
    arrlist.add(31);
    arrlist.add(49);

    // toArray copies content into other array
    Integer myArray[] = new Integer[arrlist.size()];
    myArray = arrlist.toArray(myArray);

    System.out.println(Arrays.toString(myArray));

}

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("from java2s.com");

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

    System.out.println(arrlist);/*from w  w w  .  j av a2 s.  c  om*/

    // retrieving the index of element "E"
    int retval = arrlist.indexOf("E");
    System.out.println("The element E is at index " + retval);
}

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);/*from  w w  w .jav  a  2 s . co  m*/

    // Retrieving the index of last occurrence of element "E"
    int retval = arrlist.lastIndexOf("E");
    System.out.println("The last occurrence of E is at index " + retval);

}

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);//from   w w w . j  a  v a  2s .c  om

    // 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:TestMapObjInterface.java

public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Usage: MapObjInterfaceTest <filename> <vfs name> <CN address>");
        System.out.println("MapObjInterfaceTest is a unit test of mproxy's map_obj interface."
                + "  It expects as input a filename and a Parascale vfs name.");
        System.out.println(//from ww  w .  ja va2  s  .c o m
                "It returns a listing of the chunks for the specified file" + " in the following format:");
        System.out.println();
        System.out.println("[1275] ChunkInfo: offset: 85563801600 length: 67108864 17 : "
                + "Filelength 85899345920 <0>StorageNodeInfo: nodeName: "
                + "atg-sn2 primar addr: 10.10.249.222 enabled: true up: true ");
        System.out.println();
        System.out.println("Callers may use this information to determine if the "
                + "map_obj interface is returning correct data.");
        System.exit(1);
    }
    try {
        if (args[args.length - 1].equals("auto")) {
            if (runTest(args[0], args[1], args[2])) {
                System.out.println("pass");
            } else {
                System.out.println("FAIL");
            }
        } else {
            ArrayList<String> output = getChunks(args[0], args[1], args[2]);
            if (!output.isEmpty()) {
                int i = 0;
                for (i = 0; i < output.size(); i++) {
                    System.out.println(output.get(i));
                }
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:de.netallied.functionblock.converter.java2java.util.Directory.java

public static void main(String[] params) {
    File temp = new File("C:\\Temp");
    ArrayList list = Directory.getAll(temp, true);
    Iterator it = list.iterator();
    while (it.hasNext()) {
        System.out.println(((File) (it.next())).getAbsolutePath());
    }//from  w  w w . j ava2  s .co  m
    System.out.println("Number of Files: " + list.size());
}

From source file:de.dakror.jagui.parser.NGuiParser.java

public static void main(String[] args) {
    try {/*from w w  w.  j  a  va 2s  . co m*/
        DIR.mkdirs();
        if (!new File(DIR, "convert.exe").exists())
            Helper.copyInputStream(NGuiParser.class.getResourceAsStream("/res/convert.exe"),
                    new FileOutputStream(new File(DIR, "convert.exe")));

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFileChooser jfc = new JFileChooser(
                new File(NGuiParser.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
        jfc.setMultiSelectionEnabled(false);
        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jfc.setFileFilter(new FileNameExtensionFilter("Unity ngui Gui-Skin (*.guiskin)", "guiskin"));

        if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            p("Collecting GUIDs, Converting Resources");
            HashMap<String, File> guids = collectGUIDs(jfc.getCurrentDirectory());

            p("Parsing Guiskin file");
            String s = Helper.getFileContent(jfc.getSelectedFile());
            String[] lines = s.split("\n");
            ArrayList<String> l = new ArrayList<>(Arrays.asList(lines));
            String string = "";
            for (int i = 0; i < l.size(); i++)
                if (!l.get(i).startsWith("%") && !l.get(i).startsWith("---"))
                    string += l.get(i) + "\n";

            Yaml yaml = new Yaml();
            for (Iterator<Object> iter = yaml.loadAll(string).iterator(); iter.hasNext();) {
                JSONObject o = new JSONObject((Map<?, ?>) iter.next());
                p("Cconverting Guiskin");
                replaceGuidDeep(o, guids, jfc.getSelectedFile());
                p("Writing converted file");
                Helper.setFileContent(new File(jfc.getSelectedFile().getParentFile(),
                        jfc.getSelectedFile().getName() + ".json"), o.toString(4));
                p("DONE");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US);
    Enumeration<String> keys = bundle.getKeys();
    ArrayList<String> temp = new ArrayList<String>();

    for (Enumeration<String> e = keys; keys.hasMoreElements();) {
        String key = e.nextElement();
        if (key.startsWith("java2s")) {
            temp.add(key);//from   w w  w .j  av a2 s.  c o  m
        }
    }

    String[] result = new String[temp.size()];

    for (int i = 0; i < temp.size(); i++) {
        result[i] = bundle.getString(temp.get(i));
    }
    System.out.println(Arrays.toString(result));
}

From source file:Main.java

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

    // use add() method to add elements in the list
    arrlist.add(20);//from w ww.  j  a  v a2s  .c  om
    arrlist.add(30);
    arrlist.add(10);
    arrlist.add(50);

    System.out.println(arrlist);

    // finding size of this list
    int retval = arrlist.size();
    System.out.println("List consists of " + retval + " elements");

    arrlist.clear();
    retval = arrlist.size();
    System.out.println("list consists of " + retval + " elements");
}