java – How can I check if array list contains a particular string value?

How can I check if the array of IDs in my array list contain a particular string? I’m sure the question was probably answered elsewhere but I couldn’t find anything (probably because I wasn’t searching for the right questions).

Main Activity:

ArrayList<HomeJamaatItem> arrayJamaat = new ArrayList<>();


public class HomeJamaatItem {

    private String ID;
    private String name;
    private String distance;
    private String fajrJamaat;
    private String zuhrJamaat;
    private String asrJamaat;
    private String maghribJamaat;
    private String eshaJamaat;

    public HomeJamaatItem(String ID, String name, String distance, String fajrJamaat, String zuhrJamaat, String asrJamaat, String maghribJamaat, String eshaJamaat) {
        this.ID = ID; = name;
        this.distance = distance;
        this.fajrJamaat = fajrJamaat;
        this.zuhrJamaat = zuhrJamaat;
        this.asrJamaat = asrJamaat;
        this.maghribJamaat = maghribJamaat;
        this.eshaJamaat = eshaJamaat;

    public String getID() {
        return ID;

    public String getName() {
        return name;

    public String getDistance() {
        return distance;

    public String getFajr() {
        return fajrJamaat;

    public String getZuhr() {
        return zuhrJamaat;

    public String getAsr() {
        return asrJamaat;

    public String getMaghrib() {
        return maghribJamaat;

    public String getEsha() {
        return eshaJamaat;

I’ve tried to use the .contains method but unfortunately, it didn’t work:

if (!arrayJamaat.contains("Mcdougall")) {
   // Code