intermediate/EqualsDifference

From ggc

Jump to: navigation, search

01 package intermediate;
02 
03 import java.util.*;
04 
05 /**
06  * All about my application.
07  @author My Name Here
08  */
09 public class EqualsDifference
10 {
11   public static void main(String[] args)
12   {
13     String a="Hello";
14     Scanner scanner=new Scanner(System.in);
15     String b=scanner.next();//"He"+'l'+"lo";
16     if(a==b)
17     {
18       System.out.println("They refer to the same object.");
19     }
20     else
21     {
22       System.out.println("They refer to different objects.");
23       System.out.println("The first object is "+a);
24       System.out.println("The second object is "+b);
25     }
26     if(a.equals(b))
27     {
28       System.out.println("They refer to the same contents.");
29     }
30     else
31     {
32       System.out.println("They refer to different contents.");
33       System.out.println("The first object is "+a);
34       System.out.println("The second object is "+b);
35     }
36 
37   }
38 }


Download/View intermediate/EqualsDifference.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter