Java tutorial
//package com.java2s; public class Main { /** * A generic method to get the double value from a string type. * * @param s * @return double */ public static double getDoubleValue(String s) { return (isNullOrEmpty(s) ? 0.0 : Double.valueOf(s)); } /** * A method to check whether a string is null or empty. * * @param String . * @return boolean true or false. */ public static boolean isNullOrEmpty(String s) { return s == null ? true : (s.trim().length() <= 0); } }