Example usage for java.lang Integer parseInt

List of usage examples for java.lang Integer parseInt

Introduction

In this page you can find the example usage for java.lang Integer parseInt.

Prototype

public static int parseInt(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal integer.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    int x = Integer.parseInt("123");

}

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Integer.parseInt("010"));

}

From source file:MainClass.java

public static void main(String[] arg) {
    System.out.println(Integer.parseInt("100"));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int i = Integer.parseInt("123");
    System.out.println(i);//w  w w . ja v  a 2  s .c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int i = Integer.parseInt("1023");
    String s = Integer.toString(i);
    System.out.println(s);//from   w ww  . j  ava2 s . c  o  m
}

From source file:Main.java

public static void main(String[] args) {
    int x, y;/*from w  ww . j  a  v a  2s . co  m*/

    x = Integer.parseInt("1");
    y = Integer.parseInt("2");

    if (x > y) {
        System.out.println(x + ">" + y);
    } else if (x < y) {
        System.out.println(x + "<" + y);
    } else {
        System.out.println(x + "=" + y);
    }
}

From source file:Main.java

public static void main(String[] args) {
    String str = new String("10");
    int i = Integer.parseInt(str);
    System.out.println(i);//  www  .  jav a  2 s.  c  o  m
}

From source file:Main.java

License:asdf

public static void main(String[] args) throws Exception {

    try {//from   w w w .j a v a2 s  . c o  m
        int i = Integer.parseInt("asdf");
    } catch (NumberFormatException e) {
        ;
    }
}

From source file:Main.java

public static void main(String[] args) {
    String myNumber = "13";

    Integer number = Integer.parseInt(myNumber);
    System.out.println("My lucky number is: " + number);

    number = Integer.parseInt(myNumber, 16);
    System.out.println("My lucky number is: " + number);

    number = Integer.parseInt(myNumber, 8);
    System.out.println("My lucky number is: " + number);
}

From source file:Main.java

public static void main(String[] argv) {
    String sValue = "5";
    try {/*from w w w  . ja  va  2  s.  co m*/
        int iValue = Integer.parseInt(sValue);
        System.out.println(iValue);
    } catch (NumberFormatException ex) {
        ex.printStackTrace();
    }

}