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. Imports System.Web
Imports System.Net.Mail<

View Tutorial          By: Naresh at 2011-05-24 07:27:12

2. thanku very much. it is a good examples for abstr
View Tutorial          By: rajesh at 2010-12-17 10:57:42

3. Good example...easy to read and understand...
View Tutorial          By: Codventure at 2009-09-11 00:07:06

4. Hi this is very clear and helpful, I would like to
View Tutorial          By: JoelC at 2012-11-06 16:23:19

5. I 've tried the program for Bubble Sort. This prog
View Tutorial          By: Siva at 2012-04-17 05:19:28

6. Hi,
I need to put in a picturebox on VB .NE

View Tutorial          By: Marcio Rodrigues at 2009-11-27 05:07:09

7. tnx.
i have problem why is that to slow???

View Tutorial          By: rozhin at 2015-08-21 07:54:42

8. site is good.explaining the concept with nice pro
View Tutorial          By: AJOY KUMAR MANDAL at 2012-11-22 01:57:26

9. The only thing that really was the solution to my
View Tutorial          By: nick marinho at 2010-07-24 17:45:59

10. i got really nice help from the code. Thanks.
View Tutorial          By: Amit at 2009-04-10 08:18:40