Here you can find the source of toInteger(String s)
Parameter | Description |
---|---|
s | is the string to parse as an Integer |
public static Integer toInteger(String s)
//package com.java2s; public class Main { /**/* w ww .j a va 2 s . c o m*/ * Translate a string s to an Integer. * * @param s is the string to parse as an Integer * @return the integer translation of string s, or return null if s is not * an integer. */ public static Integer toInteger(String s) { Integer i = null; try { i = Integer.parseInt(s); } catch (NumberFormatException e) { // leave i = null } return i; } public static Integer parseInt(String intStr) { try { int i = Integer.parseInt(intStr); return i; } catch (Exception e) { return null; } } }