Java – string to int example

public class Main {
  public static void main(String[] args) {
    String str = "10";
    int i = Integer.parseInt(str);
    System.out.println("Integer after parsing: " + i);
    System.out.println("Now parsing string which is not integer");
    try {
      int j = Integer.parseInt("Not integer");
    } catch (Exception e) {
OpenJDK 64-Bit Server VM warning: Insufficient space for shared memory file:
Try using the option to select an alternate temp location.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments