Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    /**
     * Parses a float.
     * If null or not a float, the default is returned.
     *
     * @param s a string
     * @param defaultValue the default
     * @return the parsed result
     */
    public static float parseFloat(String s, float defaultValue) {
        if (s == null)
            return defaultValue;
        try {
            return Float.parseFloat(s);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
}