In JAVA programming it is very frequent demand of converting an int/Integer to String.
Below snapshot shows how this is done. Easy to remember.
public class DataTypeCoversionDemo { private static String strVar = "11"; private static int intVar = 22; private static Integer integerVar = 222; public static void main(String[] args) { convertInt_String(); } public static void convertInt_String(){ // ********* Integer to int ********** // Integer tInteger = Integer.valueOf(intVar); int tSimpleIntValue = tInteger.intValue(); System.out.println("Simple Int to Integer :- " + tInteger); //22 System.out.println("Integer to Simple int :- " + tSimpleIntValue); //22 // ********* int to String ********* // String tString = String.valueOf(intVar); int tInt = Integer.parseInt(strVar); System.out.println("Simple Int to String :- " + tString); //22 System.out.println("String to Simple Int :- " + tInt); //11 // ******* Integer to String ******* // String tString2 = integerVar.toString(); Integer tInteger2 = Integer.parseInt(strVar); System.out.println("Integer to String :- " + tString2); //222 System.out.println("String to Integer :- " + tInteger2); //11 } }
Rattling superb info can be found on this blog.
filtri
Hey, can I use your article on my blog with a linkback?
Yes you can.
Thanks for visiting us.
http://magicofmakingupx.WebStarts.com Thanks for that awesome posting. It saved MUCH time 🙂
bolha
Thanks for your input and I will use it for my school research that I am doing for this website.
I really enjoy the article.Thanks Again. Keep writing.
Hi there, I found your website by the use of
Google while looking for a comparable topic, your site came
up, it looks good. I have bookmarked it in my google bookmarks.
Hi there, just became aware of your blog thru Google, and found that it is really informative.
I am going to watch out for brussels. I’ll appreciate in case you proceed this in future. A lot of folks can be benefited out of your writing. Cheers!
It seems you actually know quite a bit related to this
specific issue and this exhibits with this amazing
post, called “String to Integer « SchoolHood”.
Regards -Brianne
What’s up colleagues, how is all, and what you would like to say on the topic of this article, in my view its in fact remarkable in favor of me.
I wanted to thank you for this good read!! I certainly enjoyed every little bit
of it. I have got you bookmarked to look at new stuff you post…
Hey there! This is my first comment here so I just
wanted to give a quick shout out and say I truly
enjoy reading your articles. Can you recommend any
other blogs/websites/forums that deal with the same topics?
Thank you so much!