List of usage examples for java.util ArrayList get
public E get(int index)
From source file:Main.java
/** * Print//w ww .jav a 2 s . c om * */ public static void print(ArrayList tokens) { for (int i = 0; i < tokens.size(); i++) { System.out.print(tokens.get(i) + " "); } System.out.print("\n"); }
From source file:Main.java
public static int indexOf(ArrayList<String> list, String value) { for (int i = 0; i < list.size(); i++) { String name = list.get(i); if (value.equals(name)) { return i; }/* w ww. j av a 2 s .c o m*/ } return -1; }
From source file:Main.java
/** * Print/* w w w.j av a 2 s .c o m*/ * */ public static void print(ArrayList<?> tokens) { for (int i = 0; i < tokens.size(); i++) { System.out.print(tokens.get(i) + " "); } System.out.print("\n"); System.out.print("\n"); }
From source file:com.hackathon.gavin.account.MyAccountGenerator.java
public static MyAccount createMyAccount() { JSONArray jSONArray = MyAccountParser.httpGetCall(urlString, jsonArrayName); ArrayList arrayList = MyAccountParser.convertToArrayList(jSONArray); int ID = Integer.valueOf(arrayList.get(0).toString()); int UNITS = Integer.valueOf(arrayList.get(1).toString()); String INSTRUMENT = arrayList.get(2).toString(); double PRICE = Double.valueOf(arrayList.get(3).toString()); MyAccount myAccount = new MyAccount(ID, UNITS, INSTRUMENT, PRICE); return myAccount; }
From source file:Main.java
public static Element getFirstElementByTagName(Node node, String tagName) { ArrayList<Element> elements = getElementsByTagName(node, tagName); if (!elements.isEmpty()) return elements.get(0); return null;//from www . j av a2s .c om }
From source file:Main.java
public static Element getChildElement(Element parent, String childName) { ArrayList<Element> childElements = getChildElements(parent, childName); return childElements.size() > 0 ? childElements.get(0) : null; }
From source file:Main.java
public static ArrayList<Integer> resetIncrementalList(ArrayList<Integer> list) { for (int i = 0; i < list.size(); i++) { if (i >= 2) { list.set(i, list.get(i) + list.get(i - 2)); }// w w w.ja v a2 s . c o m } return list; }
From source file:Main.java
private static Bundle createNamePortBundle(String name, int port, TreeMap<String, ArrayList<String>> ips) { Bundle namePort = new Bundle(); namePort.putString("name", name); namePort.putInt("port", port); if (ips != null) { ArrayList<String> ip = ips.get(name); Collections.shuffle(ip, new Random()); namePort.putString("ip", ip.get(0)); }// ww w. j a v a 2 s. c om return namePort; }
From source file:Main.java
public static <T> boolean isContain(ArrayList<T> a, ArrayList<T> b) { boolean res = false; for (int i = 0; i < b.size(); i++) { if (!a.contains(b.get(i))) { break; }// ww w . java2s. c o m if (i == b.size() - 1) { res = true; } } return res; }
From source file:Main.java
public static <T> void flipStack(Stack<T> stack) { ArrayList<T> tmp = new ArrayList<>(stack); stack.clear();/*from ww w . ja va 2s . co m*/ for (int i = tmp.size() - 1; i >= 0; i--) stack.push(tmp.get(i)); }