How to use an enhanced for loop to print out the value of an ArrayList?
<p>I've been trying to figure out a way to print out values for an enhanced for loop statement for awhile now and just can't quite seem to figure out how to do it. I understand the basic concepts of an enhanced for loop but I can't seem to figure out how to use it in my scenario. </p>

<p>Here is the code:</p>

<pre><code> import java.util.ArrayList;

public class userGroup {

    ArrayList&lt;User&gt; userGroup = new ArrayList&lt;&gt;();
    User user0;

    public void addSampleData() {

    userGroup.add(user0);

    }

    public void printusername(){

       for (User x: userGroup)
           System.out.println(x);
    }
}
</code></pre>

<p>How would I implement a for loop statement in the printusername method that prints out user0 and its values? I understand that it's probably because there is an error somewhere in the creation of the ArrayList but I just can't find out where the error(s) are. Any help would be greatly appreciated by me and anybody else who may have the same issue. Thanks.</p>