Thread: Quiz Time
View Single Post
  #31 (permalink)  
Old 05-08-2008, 12:18 PM
sanjeevtarar's Avatar
sanjeevtarar sanjeevtarar is offline
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by rjuyal View Post
yes, certainly

why it was in Quiz section lol

what about

==, even if we use,
equals/equalsIgnoreCase/contentEqual

we will get the same answer "YES"

so, what was the question,

Or simply can you give us an example where
"==" is different from "equals"
Check It

Code:
public class EqualsCheck { public static void main(String[] args) { String s = "Hello"; String s1 = "Hello"; String s2 = new String("Hello"); if(s == s1) System.out.println("Yes, =="); else System.out.println("No, =="); if(s == s2) System.out.println("Yes, =="); else System.out.println("No, =="); /******************************/ if(s.equals(s1)) System.out.println("Yes, equals()"); else System.out.println("No, equals()"); if(s.equals(s2)) System.out.println("Yes, equals()"); else System.out.println("No, equals()"); /******************************/ } }
__________________
sanjeev,संजीव
Reply With Quote