Tuesday, February 25, 2014

Out out of below program.

public class ConvertStringToInt {
    public static void main(String[] args) {
        int a = Integer.parseInt("ravikiran");
        System.out.println("value of a="+a);
    }
}

O/P: Run time error

Exception in thread "main" java.lang.NumberFormatException: For input string: "ravikiran"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:492)
    at java.lang.Integer.parseInt(Integer.java:527)
    at ConvertNumbers.main(ConvertNumbers.java:4)



No comments:

Post a Comment