Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Virudada

Comment Added at : 2012-05-05 06:27:22

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
import java.util.*;

public class demo {
public static void main(String[] args) {
int q=1;
int r=2-1;
Integer t=new Integer(1);
System.out.println(q==t);
System.out.println(t.equals(r));
System.out.println(q==r);
}
}

Output -

true
true
true

Please give me the explanation.
Many thanks in advance!


View Tutorial



Related Tutorials

Java program to get location meta data from an image

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Archived Comments

1. nice
View Tutorial          By: ravi at 2010-11-26 02:46:56

2. Thanks for this article.
View Tutorial          By: Arindam Dey at 2011-06-16 05:23:17

3. I have successfully send sms after some trying....
View Tutorial          By: DILIP at 2012-01-19 14:38:50

4. return type doesn't influence the overloading. Onl
View Tutorial          By: Shekhar at 2010-05-17 01:22:04

5. when i trying to build the above program it is giv
View Tutorial          By: bhagyalaxmi at 2008-10-10 23:45:45

6. How to use it
View Tutorial          By: Ted at 2011-12-23 07:23:20

7. thank's
View Tutorial          By: gerald at 2010-08-06 01:21:39

8. Best example to explain Inheritance. thankyou for
View Tutorial          By: Suresh Lilhare at 2010-05-14 09:10:27

9. Except for when you're programming low level hardw
View Tutorial          By: Jonathan H at 2012-05-10 08:46:48

10. really very good example .now i have cleared what
View Tutorial          By: pushpendra bansal gurjar at 2012-02-15 12:19:58