searching through arraylist

i would like to now if there is a way to search through the arraylist looking for a particular value? so like im looking for vaues of 100 in the arraylist and printing them outthnx if u are able to help
[223 byte] By [cyrus666a] at [2007-11-27 1:01:41]
# 1
Do you not know how to iterate over the arraylist, and compare each item yourself while doing so?
warnerjaa at 2007-7-11 23:36:37 > top of Java-index,Java Essentials,New To Java...
# 2
i know how to iterate but dunno how u compare lol
cyrus666a at 2007-7-11 23:36:37 > top of Java-index,Java Essentials,New To Java...
# 3
== will compare two ints for equality. http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.htmlOr you could post a small example of what you have so far to iterate and test.
pbrockway2a at 2007-7-11 23:36:37 > top of Java-index,Java Essentials,New To Java...
# 4

Here's an approach:

import java.util.*;

public class Test

{

public static void main(String[] args)

{

List<Integer>list = new ArrayList<Integer>();

Collections.addAll(list, 1, 100, 2, 100, 3, 100);

List<Integer>singleton = Collections.singletonList(100);

List<Integer>copy = new ArrayList<Integer>(list);

copy.retainAll(singleton);

for(Integer n : copy)

{

System.out.println(n);

}

}

}

ChuckBinga at 2007-7-11 23:36:37 > top of Java-index,Java Essentials,New To Java...