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. not bad
View Tutorial          By: JUST_PREET at 2013-03-06 11:37:15

2. good example need some more explanation on notify
View Tutorial          By: prashant at 2009-09-08 19:29:54

3. excellent
View Tutorial          By: shamim at 2011-07-08 02:39:31

4. Nice Explanation
View Tutorial          By: sam at 2010-11-24 02:23:57

5. aishwarya.. i also have that error.. have you solv
View Tutorial          By: Geok Lin at 2009-04-06 02:26:49

6. Great examples Eric! Really helped me out a lot, m
View Tutorial          By: Markus at 2008-11-12 05:27:05

7. Hi All,

Can any one please let me k

View Tutorial          By: Deepak at 2015-03-19 15:24:40

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

9. the default implementation of validate returns nul
View Tutorial          By: Jerry at 2009-02-01 11:12:06

10. Awesome and straight forward
View Tutorial          By: Nag at 2012-11-07 23:47:10