Java Long equals Example

Long class equalsLong method example.


Long class equals method example. This example shows you how to use equals method. This method shows true if value contents are same and vice versa

Syntax:- equals(Object obj)

Here is the code:-
/**
 * @(#) EqualsLong.java 
 * EqualsLong class demonstrates the working of equals()method of Long class of lang package
 @version 9-May-2008
 @author Rose India Team
 */
public class EqualsLong {
  public static void main(String args[]) {
    // on the basis of how the valuecontents are assigned to the objects 
    // this method compares the objects equality 
    String str = "hi this is baadshah khan";
    String vtr = "hi this" "is baadshah khan";
    String vtr1 = "hi this " "is baadshah khan";
    // here the method returns false because way of assigning
    // values are not same no matter the values specified are equal in all
    // aspects of spelling, lenght etc
    
    System.out.println(str.equals(vtr"----false is returned because space between 'this' and 'is' words are not same");
    System.out.println(str.equals(vtr1"-----true is returned because now the gaps between words matches");
    
        
    Integer n1 = new Integer(47);
    Integer out = new Integer(231);
    System.out.println(n1.equals(out"----arithmetic numbers are not same");
  }
}

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US