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. any body who have a full source code of the progra
View Tutorial          By: progra at 2013-02-11 12:37:34

2. Session Bean = client data is maintained upto pred
View Tutorial          By: Chetankumar at 2012-05-19 11:12:17

3. In listing 6.2 I don't see the variable name itsAg
View Tutorial          By: JC at 2013-04-16 01:49:52

4. Nice article...
View Tutorial          By: Sudhanshu at 2012-08-02 06:19:42

5. Your Work is Good, But i want to ask if there is a
View Tutorial          By: Good Muyis at 2011-01-08 09:47:14

6. It won't work for me ;S
View Tutorial          By: jordi at 2011-01-21 08:22:45

7. Yes, its possible to send SMS through web applicat
View Tutorial          By: Vidya at 2010-07-08 07:19:58

8. this is WRONG!

your IF should be:
View Tutorial          By: notnooblikeyou at 2013-01-29 15:11:30

9. Being a freshman in blogging, I really appreciate
View Tutorial          By: tyu at 2009-09-03 08:12:32

10. hi,

i am trying to run this SMS jav

View Tutorial          By: Raghavendra at 2010-12-29 08:27:02