Here you can find the source of parseInt(String str)
Parameter | Description |
---|---|
str | The input integer value as a string |
public static int parseInt(String str)
//package com.java2s; public class Main { /**/*from w ww .j av a 2s . com*/ * Parses an string to integer by removing any non-integer character * @param str The input integer value as a string * @return The converted integer value (I.E. 1,000 becomes 1000) returns 0 if fails */ public static int parseInt(String str) { str = str.replaceAll("[^0-9]+", ""); try { return Integer.parseInt(str); } catch (Exception e) { return 0; } } }