title: Java String Validation Loop
body: <p>I have a quick question regarding Java. I'm currently studying for a coding assignment coming up regarding arrays. Essentially the assignment is making a few String arrays and randomly generating numbers to pick elements of the array. </p>
  
  <p>One of the requirements of the assignment is to do validation, the String that is a result of picking from the two arrays. Our rules for validation is that the string can't be greater than 8 characters in length. If it's greater than 8 we need to randomly generate another string that is less than or equal to 8 characters.</p>
  
  <p>I've tried using a do-while and a while(loopFlag) validation loop. But I just can't seem to get it to work properly. Typically what will happen is the console runs into an error and just gets stuck in the validation loop. I tried making an int characterLength and using the .length() method but it doesn't seem to work.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Thanks!</p>