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

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. Please tell me the process, how to compile the mid
View Tutorial          By: Manish at 2008-11-14 13:33:43

2. Dudes

I used the abov

View Tutorial          By: Nithin p at 2013-01-06 06:54:33

3. I am quite new to Struts and this article, quite c
View Tutorial          By: Jenghiz at 2010-01-27 23:19:48

4. its realy gud which clears minor douts regarding t
View Tutorial          By: Shripad at 2010-01-19 05:40:41

5. Very usefull tutorial, but I've got a question:
View Tutorial          By: Wolfgang Marcos at 2011-05-16 11:12:19

6. Hi,
i tried this way.that works perfectly.

View Tutorial          By: indu at 2009-06-08 03:13:51

7. I have one doubt regarding this code,
if th

View Tutorial          By: Yellappa at 2010-06-11 05:49:15

8. Thank you....
View Tutorial          By: Prakash at 2013-02-13 08:35:12

9. Thank you... I have the same problem , I have date
View Tutorial          By: makoy at 2012-01-16 09:06:34

10. How we print this structure in C++, with nested lo
View Tutorial          By: Hussnain at 2012-01-27 09:19:41