title: How to assign properties to a user in an Array List?
body: <p>So far I have created an Array List which only currently consists of one user. For my assignment, I have been asked to print out properties for that user such as its username and userType. As far as I aware I have created an enhanced for loop that would print out these properties if only they were assigned. My question is how would I go about assigning these properties to my user? I have created a UserGroup class in which the array list resides in and a User class in which some details about the User is specified however I am not quite sure if the User class is correct for what I am trying to achieve. Here is the code for both classes:</p>
  
  <p>UserGroup:</p>
  
  <pre><code> package main;
  import java.util.ArrayList;
  
  public class UserGroup {
  
      ArrayList&lt;User&gt; userGroup = new ArrayList&lt;&gt;();
      User userOne;
  
      public void addSampleData(String username, String userType, String name) {
  
      userGroup.add(new User("LeeB", "Staff", "Lee"));
  
  }
  
      public User getUser(int index)  {
  
      return userGroup.get(0);
  
  }
  
      public void printusername(){
  
         for (User x : userGroup)
             System.out.println(x);
  
      }
  }
  </code></pre>
  
  <p>User:</p>
  
  <pre><code> package main;
  class User {
  
    String username;
    String userType;
    String name;
  
  
      User(String username, String userType, String name) {
  
      this.username = username;
      this.userType = userType;
      this.name = name;
      }
  
    public String getUsername() {
        return username;
    }
  
    public String getUserType() {
        return userType;
    }
  
     public String getName() {
        return name;
    }
  
    public String setUserType(String admin) {
        return userType = admin;
    }
  
  }
  </code></pre>
  
  <p>Main method:</p>
  
  <pre><code>package main;
  
  public class Main {
   public static void main(String[] args) {
      for (int counter=2; counter&lt;=40; counter+=2) {
         System.out.println(counter);
      }
      System.out.println("For loop complete.");
  
      int counter = 1;
      int increment = 2;
      int loopexeccounter = 0;
      while (counter &lt;= 500) {
          loopexeccounter = loopexeccounter + 1;
          System.out.println(counter);
      counter = counter + increment++;
      }
  System.out.print("This loop iteratted "+loopexeccounter+" times.");
  }
  
      public Main() {
  
       UserGroup userGroupObject = new UserGroup();
  
   System.out.println(userGroupObject.getUser(0)); 
   }
  
  }
  </code></pre>
  
  <p>Ignore everything above the latest method, it's just some examples of loops that they wanted us to print out.</p>
  
  <p>Updated version, no errors but user(0) isn't being printed out.</p>