| Duplicate :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | 
Name: nt126004			Date: 12/03/2002
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
MS Windows 2k
5.00.2195
A DESCRIPTION OF THE PROBLEM :
When passed a null value, Integer.parseInt() throws a NumberFormatException.
However, Double.parseDouble() and Float.parseFloat() throw NullPointerException
when passed null.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected to get the same exception (NullPointerException or
NumberFormatException) in both cases
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class test {
	public static int getInt(String value, int defaultValue) {
        try {
            return Integer.parseInt(value);
        } catch(Exception nfe) {
			nfe.printStackTrace();
            return defaultValue;
        }
    }
    public static float getFloat(String value, float defaultValue) {
        try {
            return Float.parseFloat(value);
        } catch(Exception nfe) {
			nfe.printStackTrace();
            return defaultValue;
        }
    }
    public static void main(String[] args) {
        System.out.println(getInt(null, -1));
        System.out.println(getFloat(null, -1));
    }
}
---------- END SOURCE ----------
(Review ID: 178469) 
======================================================================
| 
 |