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. Hi Ramlak,
I am using jdk1.4.2 to run the a

View Tutorial          By: mounika at 2008-04-27 03:05:36

2. i get error like this :
The requested resou

View Tutorial          By: Vera Yunita at 2013-05-20 03:57:18

3. I have a site fully based on php and mysql.The log
View Tutorial          By: titus at 2011-06-14 00:52:30

4. i am newly in java. please send basic sample progr
View Tutorial          By: bhuvana at 2012-11-21 06:50:01

5. OK 0
COM1
javax.comm.CommPortIdenti

View Tutorial          By: sruthi at 2013-01-20 10:37:41

6. haii...
I am Ahmed , i am in 3rd btech ,

View Tutorial          By: Ahmed at 2014-08-09 06:30:11

7. but it will be very simple if we use pointer in it
View Tutorial          By: Hot Water Systems at 2009-06-01 03:51:48

8. I want to using swith with string...
How to

View Tutorial          By: anuj at 2015-03-04 18:22:29

9. Hi Ramalak, I am suffering with the same error as
View Tutorial          By: Divya at 2008-11-06 22:46:12

10. hi can any one help me how i can install javax.co
View Tutorial          By: Jewel at 2008-02-26 21:52:17