title: How do I convert from int to Long in Java?
body: <p>I keep finding both on here and Google people having troubles going from <code>long</code> to <code>int</code> and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from <code>int</code> to <code>Long</code>.</p>
  
  <p>The only other answers I've found were "Just set it as Long in the first place" which really doesn't address the question.</p>
  
  <p>I initially tried casting but I get a "<code>Cannot cast from int to Long</code>"</p>
  
  <pre><code>for (int i = 0; i &lt; myArrayList.size(); ++i ) {
      content = new Content();
      content.setDescription(myArrayList.get(i));
      content.setSequence((Long) i);
      session.save(content);
  }
  </code></pre>
  
  <p>As you can imagine I'm a little perplexed, I'm stuck using <code>int</code> since some content is coming in as an <code>ArrayList</code> and the entity for which I'm storing this info requires the sequence number as a Long.</p>