Java int parse from String

Introduction

The following program demonstrates parseInt().


public class Main {
  public static void main(String args[]){
    String s = "123";
    int i = Integer.parseInt(s);
    System.out.println(i);/*from w  w w. j a  v  a  2s  .  c o  m*/
    
    s = "1231";
    i = Integer.parseInt(s);
    System.out.println(i);

    s = "0123";
    i = Integer.parseInt(s);
    System.out.println(i);

    s = "123_123_12";
    i = Integer.parseInt(s);
    System.out.println(i);

  }
}



PreviousNext

Related