Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static Double doubleFromStringOrDouble(Object stringOrDouble) {
        if (stringOrDouble == null) {
            return 0.0;
        } else if (stringOrDouble instanceof String) {
            try {
                return Double.parseDouble((String) stringOrDouble);
            } catch (Exception e) {
                return 0.0;
            }
        } else if (stringOrDouble instanceof Double) {
            return (Double) stringOrDouble;
        } else {
            return 0.0;
        }
    }
}