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…


This content originally appeared on DEV Community and was authored by NJ

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);
    }   
}



This content originally appeared on DEV Community and was authored by NJ


Print Share Comment Cite Upload Translate Updates
APA

NJ | Sciencx (2023-04-29T08:28:16+00:00) How to convert String to Integer in java. Retrieved from https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/

MLA
" » How to convert String to Integer in java." NJ | Sciencx - Saturday April 29, 2023, https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/
HARVARD
NJ | Sciencx Saturday April 29, 2023 » How to convert String to Integer in java., viewed ,<https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/>
VANCOUVER
NJ | Sciencx - » How to convert String to Integer in java. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/
CHICAGO
" » How to convert String to Integer in java." NJ | Sciencx - Accessed . https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/
IEEE
" » How to convert String to Integer in java." NJ | Sciencx [Online]. Available: https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/. [Accessed: ]
rf:citation
» How to convert String to Integer in java | NJ | Sciencx | https://www.scien.cx/2023/04/29/how-to-convert-string-to-integer-in-java/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.