Convert String to int in Java

Some times we need to convert String to int in Java for android purposes. This is fairly easy using Integer class.

This can be achieved by two methods:

1. Using Integer.parseInt()

Using parseInt() method of Integer class we can convert String to int

Note : In this case the number returned by the method is primitive int.

2. Using Integer.valueOf()

Using valueOf() method we can convert String to Integer object.

Note : In this case we will instance of Integer class.

guru

Technology enthusiast. Loves to tinker with things. Always trying to create something wonderful using technology. Loves coding for Android, Raspberry pi, Arduino , Opencv and much more.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *