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



Subscribe to Tutorials

Related Tutorials

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

Java program using Method Overriding

Archived Comments

1. Thanks a lot...I've been trying to fix my apache f
View Tutorial          By: L├ízaro at 2010-01-20 03:32:07

2. @bibiki, you are right for simpler conditions what
View Tutorial          By: Marcin at 2012-04-05 02:34:13

3. sir will you please tell me how i get out of all t
View Tutorial          By: mitali at 2012-05-06 09:54:49

4. very good tutorial
View Tutorial          By: Anonymous at 2009-06-13 01:14:25

5. nice article, many thanx :)
View Tutorial          By: Unknown at 2008-10-16 21:09:02

6. to Donovan Aces #61, thank you, I am new to java &
View Tutorial          By: Joe at 2011-09-14 22:40:19

7. it would be very helpful if you demonstrated how t
View Tutorial          By: newcoder at 2011-10-24 17:40:25

8. i have been searching for this result for more tha
View Tutorial          By: nithin at 2010-08-08 12:55:18

9. Nice article, which gives an introduction for the
View Tutorial          By: Sreejith at 2008-10-28 22:58:43

10. hi this is from Ashok....
can you send the

View Tutorial          By: Ashok at 2015-04-16 11:51:51