How to convert string to int number in Java

2 Answers

0 votes
public class MyClass {
    public static void main(String args[]) {
        
        String s = "9832";
	    
	    int n = Integer.parseInt(s);			
	    
	    System.out.println(n);
    }
}

/*
                    
run:
       
9832
           
*/

 



answered May 10, 2018 by avibootz
0 votes
public class MyClass {
    public static void main(String args[]) {
        
        String s = "9832";
	    
	    int n = Integer.valueOf(s);			
	    
	    System.out.println(n);
    }
}

/*
                    
run:
       
9832
           
*/

 



answered May 10, 2018 by avibootz
...