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. Do the serialized output is displayed in the file
View Tutorial          By: Atihs at 2012-11-17 02:38:52

2. i din understand
View Tutorial          By: panda at 2011-07-14 09:35:36

3. I am very comfortable with this example, its very
View Tutorial          By: Inam at 2010-11-07 03:04:46

4. This can also prevent Outlook from using the autod
View Tutorial          By: Morgster79 at 2012-03-21 05:07:42

5. the example program that given above for recursion
View Tutorial          By: bharathi at 2012-07-17 09:31:14

6. Hi Sr,
I am doing u r program. I got error

View Tutorial          By: Dineshram P at 2011-09-06 14:11:00

7. Hi everybody.i m new to java.dont know how to deve
View Tutorial          By: saranya at 2011-01-31 22:40:17

8. Hello to Every one!! :-),HERE I'AM NOT WRITING A C
View Tutorial          By: Pulkit Malviya at 2012-08-26 14:56:18

9. Thanks for help
View Tutorial          By: Asha at 2014-12-20 08:25:48

10. HI,
I am getting this error
Error lo

View Tutorial          By: vijay bhanu at 2009-07-18 08:57:57