Java Integer Create toInt(String string)

Here you can find the source of toInt(String string)

Description

string2Int

License

Open Source License

Parameter

Parameter Description
string a parameter

Return

int

Declaration

public static int toInt(String string) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w w  w .  j a  v a 2  s  .  c  o  m
     * string2Int
     *
     * @param string
     * @return int
     */
    public static int toInt(String string) {
        String str = trim(string);
        if ("".equals(str))
            str = "0";
        return Integer.parseInt(str);
    }

    /**
     * trim
     * 
     * @param string
     * @return
     */
    public static String trim(String string) {
        if (string == null)
            return "";
        else
            return string.trim();
    }
}

Related

  1. toInt(String str, int val)
  2. toInt(String string)
  3. ToInt(String string)
  4. toInt(String string)
  5. toInt(String string)
  6. toInt(String string, int defaultValue)
  7. toInt(String string, int defaultValue)
  8. toInt(String text, int defaultValue)
  9. toInt(String v, int def)