Question: So I need to display certain elements in an arraylist that have an integer value of over 7. So far I've written this but I'm struggling to make it work. Can anyone help?

```
public Diary()
{
    jobname = new ArrayList<Job>();
}

public void priority ()
{
    int index = 0;
    while (index < jobname.size ()) {
        Job jobName = jobname.get (index);
        index ++;
        //if (jobname.get (priority)) {
        //    System.out.println (jobname);
        //}
    }
}

```

This is the Job class that is referred to by the Diary.

```
public Job(String job, int priorityNum, String day) 
{
    if (priority < 0 || priority > 10) {
        priority = 0;
    }
    else {
        priority = priorityNum;
    }
    jobname = job;
    dueDay = day;
}

public boolean isUrgent()
{
    return priority > 7;
}

public String toString ()
{
   String s = "";
   s += "Job = " + jobname + " \n";
   s += "Day Due = " + dueDay + " \n";
   s += "Priority = " + priority + " \n";

   return s;
}

```

Answer: 
You need to change your code to the following:

```
public void priority ()
{
    foreach(Job job : jobname){
        if (job.getPriority() > 7) {
            System.out.println (job);
        }
    }
}

```

Secondly, add `getPriority()` in the `Job` class that would return the value of `priority`: 

```
public String getPriority(){
    return this.priority; 
}

```
In your situation the best option would be "for each" loop.
It would look like that:

```
for(Job job: jobname)
{
   if(job.isUrgent()) System.out.println(job);    
}

```