Getting default value for primitive types

The Guava Libraries already contains that:
http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Defaults.html

Calling defaultValue will return the default value for any primitive type (as specified by the JLS), and null for any other type.

Use it like so:

import com.google.common.base.Defaults;
Defaults.defaultValue(Integer.TYPE); //will return 0

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)