Java Integer.valueOf(String s) example

Java Integer.valueOf(String s) example

By Yashwant Chavan, Views 4, Date 14-Apr-2018

In this java tutorial, You will learn how to use valueOf(String s) method of Integer class. This method, Returns an Integer object holding the value of the specified String. The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the parseInt(java.lang.String) method. A result is an Integer object that represents the integer value specified by the string

tags Java

Returns an Integer object holding the value of the specified String.


public static Integer valueOf(String s) throws NumberFormatException


s - the string to be parsed.


An Integer object holding the value represented by the string argument.


NumberFormatException - if the string cannot be parsed as an integer.

Java Integer valueOf(String s) example

  • Assign two integer values.
  • Integer.valueOf(firstValue);It will return the integer value of string firstValue.
  • Integer.valueOf(secondValue);It will return the integer value of string secondValue.
  • Print the values.
package com.technicalkeeda;

public class App {

    public static void main(String[] args) {
        String firstValue = "45";
        String secondValue = "80";

        Integer result1 = Integer.valueOf(firstValue);
        Integer result2 = Integer.valueOf(secondValue);

        System.out.println("The integer value of firstValue :- " + result1);
        System.out.println("The integer value of secondValue :- " + result2);


The integer value of firstValue :- 45
The integer value of secondValue :- 80


Hi there! I am founder of and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][]