Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

public static void main(String... args) {
    ArrayList<Boolean> list = new ArrayList<Boolean>();
    list.add(true);/* w  w w  .j  ava 2  s.c o  m*/
    boolean flag = list.get(0);
}

From source file:com.swemel.sevenzip.Extract.java

public static void main(String[] args) throws IOException {
    String fileName = "D:\\incubator\\commpressors\\test_100K_2_b.7z";
    //    SevenZFile sevenZFile = new SevenZFile(new File("D:\\incubator\\commpressors\\test_100K_2_b.7z"));
    byte[] inputData = IOUtils.toByteArray(new FileInputStream(fileName)); // 7z archive contents

    SeekableInMemoryByteChannel inMemoryByteChannel = new SeekableInMemoryByteChannel(inputData);
    SevenZFile sevenZFile = new SevenZFile(inMemoryByteChannel);

    SevenZArchiveEntry entry;//from  w  w  w.j av a  2  s. co  m
    Iterable<SevenZArchiveEntry> entrys = sevenZFile.getEntries();
    for (SevenZArchiveEntry entry1 : entrys) {
        String name = entry1.getName();
        System.out.println("name = " + name + "\t" + entry1.toString());
    }
    ArrayList<InputStream> strams = sevenZFile.getStrams();
    String str = IOUtils.toString(strams.get(10));
    System.out.println("str = " + str);
    //   entry = sevenZFile.getNextEntry();
    //   sevenZFile.read();  // read current entry's data
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<Integer> a = new ArrayList<>();
    a.add(1);/*from w  w  w.  j  av a 2 s .c o  m*/
    a.add(5);
    a.add(1);

    a.set(1, null);
    System.out.println(a.get(1));
    System.out.println(a);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    StyleSheet st = new StyleSheet();
    st.loadTagStyle("body", "leading", "16,0");
    PdfWriter.getInstance(document, new FileOutputStream("html2.pdf"));
    document.open();//from   ww  w .j av a2  s .c  om
    ArrayList p = HTMLWorker.parseToList(new FileReader("example.html"), st);
    for (int k = 0; k < p.size(); ++k)
        document.add((Element) p.get(k));
    document.close();
}

From source file:File.TXT.ReadFile.java

public static void main(String[] args) {
    // TODO code application logic here
    ReadFile rf = new ReadFile();
    ArrayList hasil = new ArrayList();
    hasil = rf.read_all_files("D:\\Belajar");
    System.out.println(hasil.get(1));
}

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");

    System.out.println(arrayList.get(0));
    System.out.println(arrayList.get(1));
    System.out.println(arrayList.get(2));
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    StyleSheet styles = new StyleSheet();
    styles.loadTagStyle("ol", "leading", "16,0");
    PdfWriter.getInstance(document, new FileOutputStream("html3.pdf"));
    document.open();/*from   w w w  .  j a v a 2 s . co  m*/
    ArrayList objects;
    objects = HTMLWorker.parseToList(new FileReader("data.html"), styles);
    for (int k = 0; k < objects.size(); ++k)
        document.add((Element) objects.get(k));
    document.close();
}

From source file:Main.java

public static void main(String[] args) {
    String givenstring = "this is a test this is a another test";
    String[] words = givenstring.split(" ");

    ArrayList<String> arr = new ArrayList<String>();
    for (int i = 0; i < words.length; i++) {
        arr.add(words[i]);/* w ww .  j  a  v  a  2s.c  o  m*/
    }
    while (arr.size() != 0) {
        String word = arr.get(0);
        int frequency = Collections.frequency(arr, word);
        arr.removeAll(Collections.singleton(word));
        System.out.println(word + frequency);
    }
}

From source file:com.github.xbn.examples.io.non_xbn.SizeOrderAllFilesInDirXmpl.java

public static final void main(String[] ignored) {
    File fDir = (new File("R:\\jeffy\\programming\\sandbox\\xbnjava\\xbn\\"));
    Collection<File> cllf = FileUtils.listFiles(fDir, (new String[] { "java" }), true);

    //Add all file paths to a Map, keyed by size.
    //It's actually a map of lists-of-files, to
    //allow multiple files that happen to have the
    //same length.

    TreeMap<Long, List<File>> tmFilesBySize = new TreeMap<Long, List<File>>();
    Iterator<File> itrf = cllf.iterator();
    while (itrf.hasNext()) {
        File f = itrf.next();/*from  w ww. j a va  2 s  .co m*/
        Long LLen = f.length();
        if (!tmFilesBySize.containsKey(LLen)) {
            ArrayList<File> alf = new ArrayList<File>();
            alf.add(f);
            tmFilesBySize.put(LLen, alf);
        } else {
            tmFilesBySize.get(LLen).add(f);
        }
    }

    //Iterate backwards by key through the map. For each
    //List<File>, iterate through the files, printing out
    //its size and path.

    ArrayList<Long> alSize = new ArrayList<Long>(tmFilesBySize.keySet());
    for (int i = alSize.size() - 1; i >= 0; i--) {
        itrf = tmFilesBySize.get(alSize.get(i)).iterator();
        while (itrf.hasNext()) {
            File f = itrf.next();
            System.out.println(f.length() + ": " + f.getPath());
        }
    }
}

From source file:Main.java

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

    arrlist.add(15);//from w  ww.  j a  v  a 2 s.c  om
    arrlist.add(22);
    arrlist.add(30);
    arrlist.add(40);

    System.out.println(arrlist);

    // retrieves element at 4th postion

    int retval = arrlist.get(3);

    System.out.println("Retrieved element is = " + retval);
}