public class ArrayListDemo {
   public static void main(String[] args) {
      
      // create an empty arraylist with an initial capacity
      ArrayList<Integer> arrlist = new ArrayList<Integer>(5);

      // use add() method to add elements in the list
      arrlist.add(15);
      arrlist.add(20);
      arrlist.add(25);
      arrlist.add(22);

      // let us print all the elements available in list
      for (Integer number : arrlist) {
         System.out.println("Number = " + number);
      }

      // this will print the size of this list
      int retval = arrlist.size();
      System.out.println("Size of list = " + retval); 
   }
}

        

public class ArrayListDemo {
    public static void main(String[] args) {
        System.out.println("Welcome to Java Program to find the length of array list");
        ArrayList < String > listOfBanks = new ArrayList < > ();
        int size = listOfBanks.size();
        System.out.println("size of array list after creating: " + size);
        listOfBanks.add("Citibank");
        listOfBanks.add("Chase");
        listOfBanks.add("Bank of America");
        size = listOfBanks.size();
        System.out.println("length of ArrayList after adding elements: " + size);
        listOfBanks.clear();
        size = listOfBanks.size();
        System.out.println("size of ArrayList after clearing elements: " + size);
    }
}

Read more: http://www.java67.com/2016/07/how-to-find-length-size-of-arraylist-in-java.html#ixzz5mVc9fKH3

        

public class GFG1 {
	public static void main(String[] argv) throws Exception {
		try {

			// Creating object of ArrayList<Integer>
			ArrayList<Integer> arrlist = new ArrayList<Integer>();

			// Populating arrlist1
			arrlist.add(1);
			arrlist.add(2);
			arrlist.add(3);
			arrlist.add(4);
			arrlist.add(5);

			// print arrlist
			System.out.println("Before operation: " + arrlist);

			// getting total size of arrlist
			// using size() method
			int size = arrlist.size();

			// print the size of arrlist
			System.out.println("Size of list = " + size);
		}

		catch (IndexOutOfBoundsException e) {

			System.out.println("Exception thrown: " + e);
		}
	}
}

        

public class GetSizeOfArrayList {

	public static void main(String[] args) {

		// Create an ArrayList and populate it with elements
		ArrayList arrayList = new ArrayList();
		arrayList.add("element_1");
		arrayList.add("element_2");
		arrayList.add("element_3");

		int elementsCount = arrayList.size();

		System.out.println("Elements in Array :");
		for(int i=0; i < elementsCount; i++)

			System.out.println(arrayList.get(i));

	}
}


        

public class Details {
	public static void main(String[] args) {
		ArrayList<Integer> al = new ArrayList<Integer>();
		System.out.println("Initial size: " + al.size());
		al.add(1);
		al.add(13);
		al.add(45);
		al.add(44);
		al.add(99);
		System.out.println("Size after few additions: " + al.size());
		al.remove(1);
		al.remove(2);
		System.out.println("Size after remove operations: " + al.size());
		System.out.println("Final ArrayList: ");
		for (int num : al) {
			System.out.println(num);
		}
	}
}


        

protected ArrayList<Object> collectCells() {
	ArrayList<Object> cells = new ArrayList<Object>();

	Platform[] platforms = ShareSDK.getPlatformList();
	if (platforms == null) {
		platforms = new Platform[0];
	}
	HashMap<String, String> hides = getHiddenPlatforms();
	if (hides == null) {
		hides = new HashMap<String, String>();
	}
	for (Platform p : platforms) {
		if (!hides.containsKey(p.getName())) {
			cells.add(p);
		}
	}

	ArrayList<CustomerLogo> customers = getCustomerLogos();
	if (customers != null && customers.size() > 0) {
		cells.addAll(customers);
	}

	return cells;
}

        

private static void a(Context context, JSONObject jSONObject, ArrayList<JSONArray> arrayList) {
	if (arrayList.size() <= 0) {
		b(context);
	}
	JSONArray jSONArray = new JSONArray();
	for (int i = 0; i < arrayList.size(); i++) {
		JSONArray jSONArray2 = (JSONArray) arrayList.get(i);
		for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
			if (jSONArray2.optJSONObject(i2) != null) {
				jSONArray.put(jSONArray2.optJSONObject(i2));
			}
		}
	}
	try {
		jSONObject.put(z[6], jSONArray);
	} catch (JSONException e) {
	}
	a = jSONObject;
	a(context, z[11], jSONObject);
}

        

public boolean hasVariableWithNameInBlock(String value)
{
    ArrayList<VariableDefinition> vd = getVariablesInBlock();
    //System.out.println(vd.size());
    for (int j = 0; j < vd.size(); j++) {
        VariableDefinition get = vd.get(j);
        //System.out.println(get.name+ " vs: "+value);
        if(get.name.equals(value))
            return true;
    }
    return false;
}

        

public static ArrayList<Projection> combine(final UWorld world, final ArrayList<Structure> village, final int chunkX, final int chunkZ, final long seed) {
	ArrayList<Projection> projections = new ArrayList<>();
	Random random = new Random(seed);
	String villageName = village.get(0).getFile().getParent();
	int side = (int) (1 + Math.sqrt(village.size()));
	for (int i = 0, maxSize = 0, offsetX = 0, offsetZ = 0; i < village.size(); ++i) {
		int posX = i % side;
		if (posX == 0) {
			offsetX = 0;
			offsetZ += maxSize;
			maxSize = 0;
		}
		Structure structure = village.get(i);
		int realX = chunkX * 16 + offsetX;
		int realZ = chunkZ * 16 + offsetZ;
		int curSize = Math.max(structure.getWidth(), structure.getLength());
		maxSize = Math.max(maxSize, curSize);
		offsetX += maxSize;
		if (!Limiter.isStructureLimitExceeded(world, structure)) {
			Projection projection = construct(world, realX, realZ, random.nextLong(), structure);
			if (projection != null) {
				projections.add(projection);
				Limiter.useStructure(world, structure);
			}
		}
	}
	new Report().post("VILLAGE", villageName).post("CHUNK", "[X=" + chunkX + ";Z=" + chunkZ + "]").post("TOTAL SPAWNED", String.valueOf(projections.size())).print();
	return projections;
}

        

public boolean needsPatching() {
	
	//Need to check if packages have changed.
	ArrayList<File> files = Ln.generateFileList(new File(AVFileVars.AVPackagesDir), false);
	try {
		ArrayList<String> last = AVFileVars.getAVPackagesListing();
		if (files.size() != last.size()) {
			if (SPGlobal.logging()) {
				SPGlobal.logMain(header, "Needs update because number of package files changed.");
			}
			return true;
		}

		for (File f : files) {
			String path = f.getPath();
			if (!last.contains(path)) {
				if (SPGlobal.logging()) {
					SPGlobal.logMain(header, "Needs update because last package list didn't contain: " + path);
				}
				return true;
			}
		}

	} catch (IOException ex) {
		SPGlobal.logException(ex);
		return true;
	}
	return false;
}        
main