Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Java Program to Convert String to Int

    This Java program converts String to Integer.

    Usually String to int conversion is required when we need to do some mathematical operations in the string variable that contains numbers. This situation normally arises whenever we receive data from user input via textfield or textarea, data is obtained as string and we required to convert string to int.

    Java Integer class has parseInt() static method, which is used convert string to int.

    Syntax:

    public static int parseInt(String s)

    Example:

    public class StrToInt {
            
     public static void main(String args[]) {
      String str = "123";
      int i = Integer.parseInt(str);
      System.out.println(str + 50); //12350 because its concatenate to value.
      System.out.println(i + 50); //173 because +(plus) is binary plus operator. 
     }
            
    }

    Program Output:

    12350
    173


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.