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

Object Equals 

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 Objects.equal() API.

File Name  :  
com/bethecoder/tutorials/guava/base_tests/ObjectsEqualTests.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.base_tests;

import com.google.common.base.Objects;

public class ObjectsEqualTests {

  /**
   @param args
   */
  public static void main(String[] args) {
    String str1 = new String("BTC");
    String str2 = new String("BTC");
    String str3 = str1;
    
    System.out.println(Objects.equal(str1, str2));
    System.out.println(Objects.equal(str1, str3));
    System.out.println(Objects.equal(str2, str3));
    
    System.out.println(Objects.equal(str1, null));
    System.out.println(Objects.equal(str2, null));
    System.out.println(Objects.equal(null, str3));
    
    System.out.println(Objects.equal(null, null));
    System.out.println(Objects.equal(""""));
  }

}
   

It gives the following output,
true
true
true

false
false
false

true
true


                    Print

   



Books Recommendation

 
 
bl  br