title: Efficiently comparing a vector to a series of numbers in Java
body: <p>I have a series of numbers, i.e. 6, 5, 7, 8, 9, 1, which through some mathematical process I will eventually obtain through repetition. For this reason, I want to use a vector to store the last six numbers yielded by this process and then compare the contents of that vector to the series of numbers above. If it identically matches the series of numbers, I will end the program, or if not continue the mathematical procedure.</p>
  
  <p>My question is I how I might go about comparing the series of numbers and the vector efficiently. Originally I was going to use a simple if/else conditional to compare each individual value in the vector with its correspondent in the series(e.g. where v is a Vector filled with six numbers, if (v.get(0) == 6 &amp;&amp; v.get(1) == 5 ...)), but considering that this will be evaluated a number of times before the vector equals the series, I'm beginning to wonder if that would be a relatively costly calculation compared to some alternate procedure.</p>
  
  <p>My other idea to do this is to store the series of numbers in a second vector and then compare the two vectors. However, being inexperienced with vectors and Java in general, I'm not sure as to how I might go about doing this and how it might be more efficient than the simple if and else clause mentioned above.</p>
  
  <p>Any advice as to how comparisons between a bunch of numbers and a vector's contents might be done more efficiently? Or if not a vector, than perhaps a list or array instead?</p>