title: HTTP Status 500 - Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
body: <p>Cannot understand why index out of bounds. The usual case of where that happens does not seem to be the problem so im a little stuck. Please Help</p>
  
  <pre><code>@Override
  @Transactional
  public Boolean RegVali(User user){
          String hql = "from User";
          Query query = sessionFactory.getCurrentSession().createQuery(hql);
  
          @SuppressWarnings("unchecked")
          List&lt;User&gt; listUser = (List&lt;User&gt;) query.list();
          int i=1;
          int j=listUser.size();
          for (Iterator&lt;User&gt; it = listUser.iterator(); it.hasNext();) {
              if(i&gt;j){
                  return true;
              }
              if(listUser.get(i).getEmail()==user.getEmail()){
                  return false;
              }
              else{
                  i++;
              }
  
      }
      return true;
  }
  </code></pre>