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



Ask a Question

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. Good.understand
View Tutorial          By: Selva at 2009-12-29 23:27:29

2. Hi Jon,

It really depends on the ap

View Tutorial          By: Hong at 2009-05-04 20:40:28

3. Hi all
Can you please tell ,how to recei

View Tutorial          By: Nanthini at 2011-09-07 16:48:04

4. thanks for this tutorial! it's very useful
View Tutorial          By: Miguel at 2011-06-26 21:15:00

5. its working... thanks.. thank you very much...!!!!
View Tutorial          By: Viswanathan at 2008-08-18 06:54:09

6. great tutorial but for me blob handling is still s
View Tutorial          By: Sarcina Saptamani at 2011-11-10 09:15:07

7. im biginner of java programming, please give me in
View Tutorial          By: siva at 2011-11-04 06:40:45

8. hi
very tnx for your code

View Tutorial          By: Moji at 2012-08-19 16:06:53

9. its not working.
View Tutorial          By: raja at 2012-08-29 11:44:45

10. nice!!!!
View Tutorial          By: svk at 2013-01-17 19:59:05