Question: I'm really good with VB and I have a project where I need to check an array. If the same item in an array exists twice or more it needs to be changed to an item that doesn't exist. Now I'm in a class where they're making us use Java for this project. 

I was wondering what is the equivalent of a for each loop in Java? I checked the JavaDocs and it only had info for the regular for loop, I didn't notice any section that said anything about a for each loop.

Answer: 
It's more subtle in Java than VB. You can find the official docs in the Oracle documentation here (towards the bottom):

[Java For Loops](https://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html)

The provided example is:

```
// Returns the sum of the elements of a

int sum(int[] a) {
    int result = 0;
    for (int i : a)
        result += i;
    return result;
}

```

Hope that helps. Be careful not to remove or add elements inside the loop or you will get a Concurrent Modification Exception.
This is called "iterating over collections". An array can be implicitly converted to a collection, so you can iterate over an array in the same way, using the "enhanced for-loop".

```
List<String> names = new LinkedList<>();

// ... add some names to the collection

for(name:names) {
  System.out.println(name);
}

```

I'm not sure if VB has collections - they are a big part of Java and I recommend you look into them. 

Of course this changes a bit in Java 8, although you'll notice a collection is still the backbone of forEach().

```
List<String> names = new LinkedList<>();

// ... add some names to the collection

names.forEach(name -> System.out.println(name));

```