Java Program to convert a string into a numeric primitive type using Integer.valueOf()


The Integer.valueOf() method is used in Java to convert a string into a numeric primitive type.

Let’s say the following is our string.

String str = "989";

To convert it into Integer primitive type, use Integer.valueOf()

Integer.valueOf(str)

Let us see the complete example to convert a string to Integer primitive type.

Example

 Live Demo

public class Demo {
    public static void main(String[] args) {
       String str = "989";
       System.out.println(Integer.valueOf(str));
    }
}

Output

989

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

407 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements