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. Your script works beautifully. Is there a way to i
View Tutorial          By: JW at 2013-05-08 22:22:44

2. we are java research students.
we are worki

View Tutorial          By: chetan at 2007-10-17 08:13:14

3. Thanks a lot. It solved my problem in a second.
View Tutorial          By: Suddy at 2010-03-25 14:56:10

4. Hi friends i have one problem am register one form
View Tutorial          By: Inbaraj at 2014-07-04 05:28:55

5. Your post helped me to resolve the SSH exception..
View Tutorial          By: Ashwini at 2008-07-14 12:47:32

6. Very good tutorial, but I have a small question he
View Tutorial          By: Mohammad NABIL at 2010-07-20 05:58:19

7. Good work. Although it would be nicer if you can p
View Tutorial          By: frisked09 at 2011-05-26 23:52:34

8. Nicely explained concept. Thankx.
View Tutorial          By: Raghvendra at 2013-01-17 07:48:18

9. @bibiki, you are right for simpler conditions what
View Tutorial          By: Marcin at 2012-04-05 02:34:13

10. very nice
View Tutorial          By: prasad at 2009-11-11 05:03:16