snipt

Ctrl+h for KB shortcuts

Java

Convert Integer to String or String to Integer

1
2
3
4
5
6
7
//Integer to String
String MyNewString = Integer.toString(MyInteger);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~

//String to Integer
Integer MyNewInteger = Integer.parseInt(MyString);
https://snipt.net/embed/d2aa974b79b73fdf30bee234b3741688/
https://snipt.net/raw/d2aa974b79b73fdf30bee234b3741688/
d2aa974b79b73fdf30bee234b3741688
java
Java
8
2016-09-27T23:54:25
True
False
False
/api/public/snipt/42779/
integer-to-string-string-to-integer
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">//Integer to String</span> </span><span id="L-2"><a name="L-2"></a><span class="n">String</span> <span class="n">MyNewString</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">toString</span><span class="o">(</span><span class="n">MyInteger</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">//~~~~~~~~~~~~~~~~~~~~~~~~~~~</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">//String to Integer</span> </span><span id="L-7"><a name="L-7"></a><span class="n">Integer</span> <span class="n">MyNewInteger</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">parseInt</span><span class="o">(</span><span class="n">MyString</span><span class="o">);</span> </span></pre></div> </td></tr></table>
android, conversion, convert, integer, java, string
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.