title: Collect successive pairs from a stream
body: <p>Given a stream such as <code>{ 0, 1, 2, 3, 4 }</code>, </p>
  
  <p>how can I most elegantly transform it into given form:</p>
  
  <p><code>{ new Pair(0, 1), new Pair(1, 2), new Pair(2, 3), new Pair(3, 4) }</code> </p>
  
  <p>(assuming, of course, I've defined class Pair)?</p>
  
  <p><strong>Edit:</strong> This isn't strictly about ints or primitive streams. The answer should be general for a stream of any type.</p>