DEV Community

realNameHidden
realNameHidden

Posted on

How to convert String to Integer in java

for explanation watch the video


import java.util.*;
import java.lang.*;
class Demo{
    public static void main(String[] args){
        String s = "9999";
        int num1 = Integer.parseInt(s);
        System.out.println(num1);
        int num2 = Integer.valueOf(s);
        System.out.println(num2);
    }   
}


Enter fullscreen mode Exit fullscreen mode

Top comments (0)