PdfArray extends PdfObject implements Iterable<PdfObject> { public int indexOf(PdfObject o) { if (o == null) return list.indexOf(null); int index = 0; for (PdfObject pdfObject : this) { if (PdfObject.equalContent(o, pdfObject)) { return index; } index++; } return -1; } PdfArray();  PdfArray(PdfObject obj);  PdfArray(PdfArray arr);  PdfArray(Rectangle rectangle);  PdfArray(List<? extends PdfObject> objects);  PdfArray(float[] numbers);  PdfArray(double[] numbers);  PdfArray(int[] numbers);  PdfArray(boolean[] values);  PdfArray(List<String> strings, boolean asNames);  PdfArray(Iterable<? extends PdfObject> objects, int initialCapacity); int size(); boolean isEmpty(); boolean contains(PdfObject o); Iterator<PdfObject> iterator(); void add(PdfObject pdfObject); void add(int index, PdfObject element); PdfObject set(int index, PdfObject element); void addAll(Collection<PdfObject> c); void addAll(PdfArray a); PdfObject get(int index); void remove(int index); void remove(PdfObject o); void clear(); int indexOf(PdfObject o); List<PdfObject> subList(int fromIndex, int toIndex); @Override byte getType(); @Override String toString(); PdfObject get(int index, boolean asDirect); PdfArray getAsArray(int index); PdfDictionary getAsDictionary(int index); PdfStream getAsStream(int index); PdfNumber getAsNumber(int index); PdfName getAsName(int index); PdfString getAsString(int index); PdfBoolean getAsBoolean(int index); Rectangle toRectangle(); float[] toFloatArray(); double[] toDoubleArray(); long[] toLongArray(); int[] toIntArray(); boolean[] toBooleanArray();  }
@Test public void testIndexOf() { PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfArray array = new PdfArray(); array.add(new PdfNumber(1).makeIndirect(doc).getIndirectReference()); array.add(new PdfNumber(2).makeIndirect(doc).getIndirectReference()); array.add(new PdfNumber(3).makeIndirect(doc)); array.add(new PdfNumber(4).makeIndirect(doc)); array.add(new PdfNumber(5)); array.add(new PdfNumber(6)); PdfArray array2 = new PdfArray(); array2.add(new PdfNumber(1).makeIndirect(doc).getIndirectReference()); array2.add(new PdfNumber(2).makeIndirect(doc).getIndirectReference()); array2.add(new PdfNumber(3).makeIndirect(doc)); array2.add(new PdfNumber(4).makeIndirect(doc)); array2.add(new PdfNumber(5)); array2.add(new PdfNumber(6)); int i = 0; for (PdfObject obj : array2) { Assert.assertEquals(i++, array.indexOf(obj)); } }