Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static float parseFloat(String f, float def) { if (f == null) { return def; } else { try { return Float.parseFloat(f); } catch (NumberFormatException ex) { return 0; } } } public static float parseFloat(String f) { if (f == null) { return 0; } else { try { return Float.parseFloat(f); } catch (NumberFormatException ex) { return 0; } } } }