 <p>You need to use <code>4545454545l</code> or <code>4545454545L</code> to qualify it as <code>long</code>. Be default , <code>4545454545</code> is an <code>int</code> literal and <code>4545454545</code> is out of range of <code>int</code>.</p> <p><em>It is recommended to use uppercase alphabet <code>L</code> to avoid confusion , as <code>l</code> and <code>1</code> looks pretty similar</em></p> <p>You can do :</p> <pre><code>if(Long.valueOf(4545454545l).equals(Long.parseLong(morse)) ){ System.out.println("2"); } </code></pre> <p>OR</p> <pre><code>if(Long.parseLong(morse) == 4545454545l){ System.out.println("2"); } </code></pre> <p>As per <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.1">JLS 3.10.1</a>:</p> <blockquote> <p>An integer literal is of type long if it is suffixed with <strong>an ASCII letter L or l (ell)</strong>; otherwise it is of type int (§4.2.1).</p> </blockquote>