tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Basic > Defaults

Defaults 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Defaults.defaultValue() API. It returns the default value for the given type.

File Name  :  
com/bethecoder/tutorials/guava/base_tests/DefaultsTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.guava.base_tests;

import java.util.List;

import com.google.common.base.Defaults;

public class DefaultsTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    System.out.println(Defaults.defaultValue(int.class));
    System.out.println(Defaults.defaultValue(char.class));
    System.out.println(Defaults.defaultValue(short.class));
    System.out.println(Defaults.defaultValue(boolean.class));
    System.out.println(Defaults.defaultValue(List.class));
  }

}
   

It gives the following output,
0
ö
0
false
null



 
  


  
bl  br